Skip to content

Commit 694dcea

Browse files
authored
Merge pull request #2154 from github/nora/split-commands-b
Extension Telemetry: Split `viewCfg`,`quickEval`, `openReferencedFile` command
2 parents 83d1450 + c0c7574 commit 694dcea

2 files changed

Lines changed: 115 additions & 5 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,22 @@
338338
"command": "codeQL.quickEval",
339339
"title": "CodeQL: Quick Evaluation"
340340
},
341+
{
342+
"command": "codeQL.quickEvalContextEditor",
343+
"title": "CodeQL: Quick Evaluation"
344+
},
341345
{
342346
"command": "codeQL.openReferencedFile",
343347
"title": "CodeQL: Open Referenced File"
344348
},
349+
{
350+
"command": "codeQL.openReferencedFileContextEditor",
351+
"title": "CodeQL: Open Referenced File"
352+
},
353+
{
354+
"command": "codeQL.openReferencedFileContextExplorer",
355+
"title": "CodeQL: Open Referenced File"
356+
},
345357
{
346358
"command": "codeQL.previewQueryHelp",
347359
"title": "CodeQL: Preview Query Help"
@@ -449,6 +461,14 @@
449461
"command": "codeQL.viewCfg",
450462
"title": "CodeQL: View CFG"
451463
},
464+
{
465+
"command": "codeQL.viewCfgContextExplorer",
466+
"title": "CodeQL: View CFG"
467+
},
468+
{
469+
"command": "codeQL.viewCfgContextEditor",
470+
"title": "CodeQL: View CFG"
471+
},
452472
{
453473
"command": "codeQL.upgradeCurrentDatabase",
454474
"title": "CodeQL: Upgrade Current Database"
@@ -947,7 +967,7 @@
947967
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
948968
},
949969
{
950-
"command": "codeQL.viewCfg",
970+
"command": "codeQL.viewCfgContextExplorer",
951971
"group": "9_qlCommands",
952972
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
953973
},
@@ -957,7 +977,7 @@
957977
"when": "resourceScheme != codeql-zip-archive"
958978
},
959979
{
960-
"command": "codeQL.openReferencedFile",
980+
"command": "codeQL.openReferencedFileContextExplorer",
961981
"group": "9_qlCommands",
962982
"when": "resourceExtname == .qlref"
963983
},
@@ -1004,10 +1024,22 @@
10041024
"command": "codeQL.quickEval",
10051025
"when": "editorLangId == ql"
10061026
},
1027+
{
1028+
"command": "codeQL.quickEvalContextEditor",
1029+
"when": "false"
1030+
},
10071031
{
10081032
"command": "codeQL.openReferencedFile",
10091033
"when": "resourceExtname == .qlref"
10101034
},
1035+
{
1036+
"command": "codeQL.openReferencedFileContextEditor",
1037+
"when": "false"
1038+
},
1039+
{
1040+
"command": "codeQL.openReferencedFileContextExplorer",
1041+
"when": "false"
1042+
},
10111043
{
10121044
"command": "codeQL.previewQueryHelp",
10131045
"when": "resourceExtname == .qhelp && isWorkspaceTrusted"
@@ -1032,6 +1064,14 @@
10321064
"command": "codeQL.viewCfg",
10331065
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
10341066
},
1067+
{
1068+
"command": "codeQL.viewCfgContextExplorer",
1069+
"when": "false"
1070+
},
1071+
{
1072+
"command": "codeQL.viewCfgContextEditor",
1073+
"when": "false"
1074+
},
10351075
{
10361076
"command": "codeQLVariantAnalysisRepositories.openConfigFile",
10371077
"when": "false"
@@ -1263,15 +1303,15 @@
12631303
"when": "resourceScheme == codeql-zip-archive"
12641304
},
12651305
{
1266-
"command": "codeQL.viewCfg",
1306+
"command": "codeQL.viewCfgContextEditor",
12671307
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
12681308
},
12691309
{
1270-
"command": "codeQL.quickEval",
1310+
"command": "codeQL.quickEvalContextEditor",
12711311
"when": "editorLangId == ql"
12721312
},
12731313
{
1274-
"command": "codeQL.openReferencedFile",
1314+
"command": "codeQL.openReferencedFileContextEditor",
12751315
"when": "resourceExtname == .qlref"
12761316
},
12771317
{

extensions/ql-vscode/src/extension.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ async function activateWithInstalledDistribution(
10741074
queryServerLogger,
10751075
),
10761076
);
1077+
10771078
ctx.subscriptions.push(
10781079
commandRunnerWithProgress(
10791080
"codeQL.quickEval",
@@ -1091,6 +1092,24 @@ async function activateWithInstalledDistribution(
10911092
),
10921093
);
10931094

1095+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.quickEval" command
1096+
ctx.subscriptions.push(
1097+
commandRunnerWithProgress(
1098+
"codeQL.quickEvalContextEditor",
1099+
async (
1100+
progress: ProgressCallback,
1101+
token: CancellationToken,
1102+
uri: Uri | undefined,
1103+
) => await compileAndRunQuery(true, uri, progress, token, undefined),
1104+
{
1105+
title: "Running query",
1106+
cancellable: true,
1107+
},
1108+
// Open the query server logger on error since that's usually where the interesting errors appear.
1109+
queryServerLogger,
1110+
),
1111+
);
1112+
10941113
ctx.subscriptions.push(
10951114
commandRunnerWithProgress(
10961115
"codeQL.codeLensQuickEval",
@@ -1311,6 +1330,19 @@ async function activateWithInstalledDistribution(
13111330
commandRunner("codeQL.openReferencedFile", openReferencedFile),
13121331
);
13131332

1333+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
1334+
ctx.subscriptions.push(
1335+
commandRunner("codeQL.openReferencedFileContextEditor", openReferencedFile),
1336+
);
1337+
1338+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
1339+
ctx.subscriptions.push(
1340+
commandRunner(
1341+
"codeQL.openReferencedFileContextExplorer",
1342+
openReferencedFile,
1343+
),
1344+
);
1345+
13141346
ctx.subscriptions.push(
13151347
commandRunner("codeQL.previewQueryHelp", previewQueryHelp),
13161348
);
@@ -1576,6 +1608,44 @@ async function activateWithInstalledDistribution(
15761608
),
15771609
);
15781610

1611+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command
1612+
ctx.subscriptions.push(
1613+
commandRunnerWithProgress(
1614+
"codeQL.viewCfgContextExplorer",
1615+
async (progress: ProgressCallback, token: CancellationToken) => {
1616+
const res = await cfgTemplateProvider.provideCfgUri(
1617+
window.activeTextEditor?.document,
1618+
);
1619+
if (res) {
1620+
await compileAndRunQuery(false, res[0], progress, token, undefined);
1621+
}
1622+
},
1623+
{
1624+
title: "Calculating Control Flow Graph",
1625+
cancellable: true,
1626+
},
1627+
),
1628+
);
1629+
1630+
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command
1631+
ctx.subscriptions.push(
1632+
commandRunnerWithProgress(
1633+
"codeQL.viewCfgContextEditor",
1634+
async (progress: ProgressCallback, token: CancellationToken) => {
1635+
const res = await cfgTemplateProvider.provideCfgUri(
1636+
window.activeTextEditor?.document,
1637+
);
1638+
if (res) {
1639+
await compileAndRunQuery(false, res[0], progress, token, undefined);
1640+
}
1641+
},
1642+
{
1643+
title: "Calculating Control Flow Graph",
1644+
cancellable: true,
1645+
},
1646+
),
1647+
);
1648+
15791649
const mockServer = new VSCodeMockGitHubApiServer(ctx);
15801650
ctx.subscriptions.push(mockServer);
15811651
ctx.subscriptions.push(

0 commit comments

Comments
 (0)