Skip to content

Commit 83d1450

Browse files
authored
Merge pull request #2142 from github/nora/split-commands-a
Extension Telemetry: Split `runVariantAnalysis` and `viewAst` command
2 parents 1db2bc0 + 7f32439 commit 83d1450

2 files changed

Lines changed: 107 additions & 26 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@
322322
"command": "codeQL.runVariantAnalysis",
323323
"title": "CodeQL: Run Variant Analysis"
324324
},
325+
{
326+
"command": "codeQL.runVariantAnalysisContextEditor",
327+
"title": "CodeQL: Run Variant Analysis"
328+
},
325329
{
326330
"command": "codeQL.exportSelectedVariantAnalysisResults",
327331
"title": "CodeQL: Export Variant Analysis Results"
@@ -433,6 +437,14 @@
433437
"command": "codeQL.viewAst",
434438
"title": "CodeQL: View AST"
435439
},
440+
{
441+
"command": "codeQL.viewAstContextExplorer",
442+
"title": "CodeQL: View AST"
443+
},
444+
{
445+
"command": "codeQL.viewAstContextEditor",
446+
"title": "CodeQL: View AST"
447+
},
436448
{
437449
"command": "codeQL.viewCfg",
438450
"title": "CodeQL: View CFG"
@@ -930,7 +942,7 @@
930942
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder || resourceExtname == .zip"
931943
},
932944
{
933-
"command": "codeQL.viewAst",
945+
"command": "codeQL.viewAstContextExplorer",
934946
"group": "9_qlCommands",
935947
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
936948
},
@@ -981,7 +993,8 @@
981993
"when": "editorLangId == ql && resourceExtname == .ql"
982994
},
983995
{
984-
"command": "codeQL.exportSelectedVariantAnalysisResults"
996+
"command": "codeQL.runVariantAnalysisContextEditor",
997+
"when": "false"
985998
},
986999
{
9871000
"command": "codeQL.runQueries",
@@ -1007,6 +1020,14 @@
10071020
"command": "codeQL.viewAst",
10081021
"when": "resourceScheme == codeql-zip-archive"
10091022
},
1023+
{
1024+
"command": "codeQL.viewAstContextEditor",
1025+
"when": "false"
1026+
},
1027+
{
1028+
"command": "codeQL.viewAstContextExplorer",
1029+
"when": "false"
1030+
},
10101031
{
10111032
"command": "codeQL.viewCfg",
10121033
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
@@ -1234,11 +1255,11 @@
12341255
"when": "editorLangId == ql && resourceExtname == .ql"
12351256
},
12361257
{
1237-
"command": "codeQL.runVariantAnalysis",
1258+
"command": "codeQL.runVariantAnalysisContextEditor",
12381259
"when": "editorLangId == ql && resourceExtname == .ql"
12391260
},
12401261
{
1241-
"command": "codeQL.viewAst",
1262+
"command": "codeQL.viewAstContextEditor",
12421263
"when": "resourceScheme == codeql-zip-archive"
12431264
},
12441265
{

extensions/ql-vscode/src/extension.ts

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,27 +1125,48 @@ async function activateWithInstalledDistribution(
11251125
),
11261126
);
11271127

1128-
// The "runVariantAnalysis" command is internal-only.
1128+
async function runVariantAnalysis(
1129+
progress: ProgressCallback,
1130+
token: CancellationToken,
1131+
uri: Uri | undefined,
1132+
): Promise<void> {
1133+
progress({
1134+
maxStep: 5,
1135+
step: 0,
1136+
message: "Getting credentials",
1137+
});
1138+
1139+
await variantAnalysisManager.runVariantAnalysis(
1140+
uri || window.activeTextEditor?.document.uri,
1141+
progress,
1142+
token,
1143+
);
1144+
}
1145+
11291146
ctx.subscriptions.push(
11301147
commandRunnerWithProgress(
11311148
"codeQL.runVariantAnalysis",
11321149
async (
11331150
progress: ProgressCallback,
11341151
token: CancellationToken,
11351152
uri: Uri | undefined,
1136-
) => {
1137-
progress({
1138-
maxStep: 5,
1139-
step: 0,
1140-
message: "Getting credentials",
1141-
});
1142-
1143-
await variantAnalysisManager.runVariantAnalysis(
1144-
uri || window.activeTextEditor?.document.uri,
1145-
progress,
1146-
token,
1147-
);
1153+
) => await runVariantAnalysis(progress, token, uri),
1154+
{
1155+
title: "Run Variant Analysis",
1156+
cancellable: true,
11481157
},
1158+
),
1159+
);
1160+
1161+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
1162+
ctx.subscriptions.push(
1163+
commandRunnerWithProgress(
1164+
"codeQL.runVariantAnalysisContextEditor",
1165+
async (
1166+
progress: ProgressCallback,
1167+
token: CancellationToken,
1168+
uri: Uri | undefined,
1169+
) => await runVariantAnalysis(progress, token, uri),
11491170
{
11501171
title: "Run Variant Analysis",
11511172
cancellable: true,
@@ -1474,23 +1495,62 @@ async function activateWithInstalledDistribution(
14741495
const cfgTemplateProvider = new TemplatePrintCfgProvider(cliServer, dbm);
14751496

14761497
ctx.subscriptions.push(astViewer);
1498+
1499+
async function viewAst(
1500+
progress: ProgressCallback,
1501+
token: CancellationToken,
1502+
selectedFile: Uri,
1503+
): Promise<void> {
1504+
const ast = await printAstTemplateProvider.provideAst(
1505+
progress,
1506+
token,
1507+
selectedFile ?? window.activeTextEditor?.document.uri,
1508+
);
1509+
if (ast) {
1510+
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
1511+
}
1512+
}
1513+
14771514
ctx.subscriptions.push(
14781515
commandRunnerWithProgress(
14791516
"codeQL.viewAst",
14801517
async (
14811518
progress: ProgressCallback,
14821519
token: CancellationToken,
14831520
selectedFile: Uri,
1484-
) => {
1485-
const ast = await printAstTemplateProvider.provideAst(
1486-
progress,
1487-
token,
1488-
selectedFile ?? window.activeTextEditor?.document.uri,
1489-
);
1490-
if (ast) {
1491-
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
1492-
}
1521+
) => await viewAst(progress, token, selectedFile),
1522+
{
1523+
cancellable: true,
1524+
title: "Calculate AST",
1525+
},
1526+
),
1527+
);
1528+
1529+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
1530+
ctx.subscriptions.push(
1531+
commandRunnerWithProgress(
1532+
"codeQL.viewAstContextExplorer",
1533+
async (
1534+
progress: ProgressCallback,
1535+
token: CancellationToken,
1536+
selectedFile: Uri,
1537+
) => await viewAst(progress, token, selectedFile),
1538+
{
1539+
cancellable: true,
1540+
title: "Calculate AST",
14931541
},
1542+
),
1543+
);
1544+
1545+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
1546+
ctx.subscriptions.push(
1547+
commandRunnerWithProgress(
1548+
"codeQL.viewAstContextEditor",
1549+
async (
1550+
progress: ProgressCallback,
1551+
token: CancellationToken,
1552+
selectedFile: Uri,
1553+
) => await viewAst(progress, token, selectedFile),
14941554
{
14951555
cancellable: true,
14961556
title: "Calculate AST",

0 commit comments

Comments
 (0)