Merge pull request #2142 from github/nora/split-commands-a
Extension Telemetry: Split `runVariantAnalysis` and `viewAst` command
This commit is contained in:
@@ -322,6 +322,10 @@
|
|||||||
"command": "codeQL.runVariantAnalysis",
|
"command": "codeQL.runVariantAnalysis",
|
||||||
"title": "CodeQL: Run Variant Analysis"
|
"title": "CodeQL: Run Variant Analysis"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "codeQL.runVariantAnalysisContextEditor",
|
||||||
|
"title": "CodeQL: Run Variant Analysis"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.exportSelectedVariantAnalysisResults",
|
"command": "codeQL.exportSelectedVariantAnalysisResults",
|
||||||
"title": "CodeQL: Export Variant Analysis Results"
|
"title": "CodeQL: Export Variant Analysis Results"
|
||||||
@@ -433,6 +437,14 @@
|
|||||||
"command": "codeQL.viewAst",
|
"command": "codeQL.viewAst",
|
||||||
"title": "CodeQL: View AST"
|
"title": "CodeQL: View AST"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "codeQL.viewAstContextExplorer",
|
||||||
|
"title": "CodeQL: View AST"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "codeQL.viewAstContextEditor",
|
||||||
|
"title": "CodeQL: View AST"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.viewCfg",
|
"command": "codeQL.viewCfg",
|
||||||
"title": "CodeQL: View CFG"
|
"title": "CodeQL: View CFG"
|
||||||
@@ -930,7 +942,7 @@
|
|||||||
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder || resourceExtname == .zip"
|
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder || resourceExtname == .zip"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.viewAst",
|
"command": "codeQL.viewAstContextExplorer",
|
||||||
"group": "9_qlCommands",
|
"group": "9_qlCommands",
|
||||||
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
|
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
|
||||||
},
|
},
|
||||||
@@ -981,7 +993,8 @@
|
|||||||
"when": "editorLangId == ql && resourceExtname == .ql"
|
"when": "editorLangId == ql && resourceExtname == .ql"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.exportSelectedVariantAnalysisResults"
|
"command": "codeQL.runVariantAnalysisContextEditor",
|
||||||
|
"when": "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.runQueries",
|
"command": "codeQL.runQueries",
|
||||||
@@ -1007,6 +1020,14 @@
|
|||||||
"command": "codeQL.viewAst",
|
"command": "codeQL.viewAst",
|
||||||
"when": "resourceScheme == codeql-zip-archive"
|
"when": "resourceScheme == codeql-zip-archive"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "codeQL.viewAstContextEditor",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "codeQL.viewAstContextExplorer",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.viewCfg",
|
"command": "codeQL.viewCfg",
|
||||||
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
|
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
|
||||||
@@ -1234,11 +1255,11 @@
|
|||||||
"when": "editorLangId == ql && resourceExtname == .ql"
|
"when": "editorLangId == ql && resourceExtname == .ql"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.runVariantAnalysis",
|
"command": "codeQL.runVariantAnalysisContextEditor",
|
||||||
"when": "editorLangId == ql && resourceExtname == .ql"
|
"when": "editorLangId == ql && resourceExtname == .ql"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.viewAst",
|
"command": "codeQL.viewAstContextEditor",
|
||||||
"when": "resourceScheme == codeql-zip-archive"
|
"when": "resourceScheme == codeql-zip-archive"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1125,7 +1125,24 @@ async function activateWithInstalledDistribution(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// The "runVariantAnalysis" command is internal-only.
|
async function runVariantAnalysis(
|
||||||
|
progress: ProgressCallback,
|
||||||
|
token: CancellationToken,
|
||||||
|
uri: Uri | undefined,
|
||||||
|
): Promise<void> {
|
||||||
|
progress({
|
||||||
|
maxStep: 5,
|
||||||
|
step: 0,
|
||||||
|
message: "Getting credentials",
|
||||||
|
});
|
||||||
|
|
||||||
|
await variantAnalysisManager.runVariantAnalysis(
|
||||||
|
uri || window.activeTextEditor?.document.uri,
|
||||||
|
progress,
|
||||||
|
token,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.subscriptions.push(
|
ctx.subscriptions.push(
|
||||||
commandRunnerWithProgress(
|
commandRunnerWithProgress(
|
||||||
"codeQL.runVariantAnalysis",
|
"codeQL.runVariantAnalysis",
|
||||||
@@ -1133,19 +1150,23 @@ async function activateWithInstalledDistribution(
|
|||||||
progress: ProgressCallback,
|
progress: ProgressCallback,
|
||||||
token: CancellationToken,
|
token: CancellationToken,
|
||||||
uri: Uri | undefined,
|
uri: Uri | undefined,
|
||||||
) => {
|
) => await runVariantAnalysis(progress, token, uri),
|
||||||
progress({
|
{
|
||||||
maxStep: 5,
|
title: "Run Variant Analysis",
|
||||||
step: 0,
|
cancellable: true,
|
||||||
message: "Getting credentials",
|
|
||||||
});
|
|
||||||
|
|
||||||
await variantAnalysisManager.runVariantAnalysis(
|
|
||||||
uri || window.activeTextEditor?.document.uri,
|
|
||||||
progress,
|
|
||||||
token,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
|
||||||
|
ctx.subscriptions.push(
|
||||||
|
commandRunnerWithProgress(
|
||||||
|
"codeQL.runVariantAnalysisContextEditor",
|
||||||
|
async (
|
||||||
|
progress: ProgressCallback,
|
||||||
|
token: CancellationToken,
|
||||||
|
uri: Uri | undefined,
|
||||||
|
) => await runVariantAnalysis(progress, token, uri),
|
||||||
{
|
{
|
||||||
title: "Run Variant Analysis",
|
title: "Run Variant Analysis",
|
||||||
cancellable: true,
|
cancellable: true,
|
||||||
@@ -1474,6 +1495,22 @@ async function activateWithInstalledDistribution(
|
|||||||
const cfgTemplateProvider = new TemplatePrintCfgProvider(cliServer, dbm);
|
const cfgTemplateProvider = new TemplatePrintCfgProvider(cliServer, dbm);
|
||||||
|
|
||||||
ctx.subscriptions.push(astViewer);
|
ctx.subscriptions.push(astViewer);
|
||||||
|
|
||||||
|
async function viewAst(
|
||||||
|
progress: ProgressCallback,
|
||||||
|
token: CancellationToken,
|
||||||
|
selectedFile: Uri,
|
||||||
|
): Promise<void> {
|
||||||
|
const ast = await printAstTemplateProvider.provideAst(
|
||||||
|
progress,
|
||||||
|
token,
|
||||||
|
selectedFile ?? window.activeTextEditor?.document.uri,
|
||||||
|
);
|
||||||
|
if (ast) {
|
||||||
|
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx.subscriptions.push(
|
ctx.subscriptions.push(
|
||||||
commandRunnerWithProgress(
|
commandRunnerWithProgress(
|
||||||
"codeQL.viewAst",
|
"codeQL.viewAst",
|
||||||
@@ -1481,16 +1518,39 @@ async function activateWithInstalledDistribution(
|
|||||||
progress: ProgressCallback,
|
progress: ProgressCallback,
|
||||||
token: CancellationToken,
|
token: CancellationToken,
|
||||||
selectedFile: Uri,
|
selectedFile: Uri,
|
||||||
) => {
|
) => await viewAst(progress, token, selectedFile),
|
||||||
const ast = await printAstTemplateProvider.provideAst(
|
{
|
||||||
progress,
|
cancellable: true,
|
||||||
token,
|
title: "Calculate AST",
|
||||||
selectedFile ?? window.activeTextEditor?.document.uri,
|
|
||||||
);
|
|
||||||
if (ast) {
|
|
||||||
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
|
||||||
|
ctx.subscriptions.push(
|
||||||
|
commandRunnerWithProgress(
|
||||||
|
"codeQL.viewAstContextExplorer",
|
||||||
|
async (
|
||||||
|
progress: ProgressCallback,
|
||||||
|
token: CancellationToken,
|
||||||
|
selectedFile: Uri,
|
||||||
|
) => await viewAst(progress, token, selectedFile),
|
||||||
|
{
|
||||||
|
cancellable: true,
|
||||||
|
title: "Calculate AST",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
|
||||||
|
ctx.subscriptions.push(
|
||||||
|
commandRunnerWithProgress(
|
||||||
|
"codeQL.viewAstContextEditor",
|
||||||
|
async (
|
||||||
|
progress: ProgressCallback,
|
||||||
|
token: CancellationToken,
|
||||||
|
selectedFile: Uri,
|
||||||
|
) => await viewAst(progress, token, selectedFile),
|
||||||
{
|
{
|
||||||
cancellable: true,
|
cancellable: true,
|
||||||
title: "Calculate AST",
|
title: "Calculate AST",
|
||||||
|
|||||||
Reference in New Issue
Block a user