Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@
"command": "codeQL.runVariantAnalysis",
"title": "CodeQL: Run Variant Analysis"
},
{
"command": "codeQL.runVariantAnalysisContextEditor",
"title": "CodeQL: Run Variant Analysis"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults",
"title": "CodeQL: Export Variant Analysis Results"
Expand Down Expand Up @@ -433,6 +437,14 @@
"command": "codeQL.viewAst",
"title": "CodeQL: View AST"
},
{
"command": "codeQL.viewAstContextExplorer",
"title": "CodeQL: View AST"
},
{
"command": "codeQL.viewAstContextEditor",
"title": "CodeQL: View AST"
},
{
"command": "codeQL.viewCfg",
"title": "CodeQL: View CFG"
Expand Down Expand Up @@ -930,7 +942,7 @@
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder || resourceExtname == .zip"
},
{
"command": "codeQL.viewAst",
"command": "codeQL.viewAstContextExplorer",
"group": "9_qlCommands",
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
},
Expand Down Expand Up @@ -981,7 +993,8 @@
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults"
"command": "codeQL.runVariantAnalysisContextEditor",
"when": "false"
},
{
"command": "codeQL.runQueries",
Expand All @@ -1007,6 +1020,14 @@
"command": "codeQL.viewAst",
"when": "resourceScheme == codeql-zip-archive"
},
{
"command": "codeQL.viewAstContextEditor",
"when": "false"
},
{
"command": "codeQL.viewAstContextExplorer",
"when": "false"
},
{
"command": "codeQL.viewCfg",
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
Expand Down Expand Up @@ -1234,11 +1255,11 @@
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.runVariantAnalysis",
"command": "codeQL.runVariantAnalysisContextEditor",
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.viewAst",
"command": "codeQL.viewAstContextEditor",
"when": "resourceScheme == codeql-zip-archive"
},
{
Expand Down
104 changes: 82 additions & 22 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,27 +1125,48 @@ 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(
commandRunnerWithProgress(
"codeQL.runVariantAnalysis",
async (
progress: ProgressCallback,
token: CancellationToken,
uri: Uri | undefined,
) => {
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});

await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
) => await runVariantAnalysis(progress, token, uri),
{
title: "Run Variant Analysis",
cancellable: true,
},
),
);

// 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",
cancellable: true,
Expand Down Expand Up @@ -1474,23 +1495,62 @@ async function activateWithInstalledDistribution(
const cfgTemplateProvider = new TemplatePrintCfgProvider(cliServer, dbm);

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(
commandRunnerWithProgress(
"codeQL.viewAst",
async (
progress: ProgressCallback,
token: CancellationToken,
selectedFile: Uri,
) => {
const ast = await printAstTemplateProvider.provideAst(
progress,
token,
selectedFile ?? window.activeTextEditor?.document.uri,
);
if (ast) {
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
}
) => 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.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,
title: "Calculate AST",
Expand Down