Skip to content

Commit 1909fee

Browse files
committed
Remove use of commandRunnerWithProgress in AST and CFG commands
1 parent 6ff2670 commit 1909fee

File tree

1 file changed

+46
-61
lines changed

1 file changed

+46
-61
lines changed

extensions/ql-vscode/src/ast-cfg-commands.ts

Lines changed: 46 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CancellationToken, ExtensionContext, Uri, window } from "vscode";
2-
import { commandRunnerWithProgress, ProgressCallback } from "./commandRunner";
2+
import { commandRunner, ProgressCallback, withProgress } from "./commandRunner";
33
import { AstViewer } from "./astViewer";
44
import {
55
TemplatePrintAstProvider,
@@ -36,86 +36,71 @@ export function registerAstCfgCommands(
3636
cfgTemplateProvider,
3737
}: AstCfgOptions,
3838
) {
39-
const viewAstCommand = async (
40-
progress: ProgressCallback,
41-
token: CancellationToken,
42-
selectedFile: Uri,
43-
) =>
44-
await viewAst(
45-
astViewer,
46-
astTemplateProvider,
47-
progress,
48-
token,
49-
selectedFile,
39+
const viewAstCommand = async (selectedFile: Uri) =>
40+
withProgress(
41+
async (progress, token) =>
42+
await viewAst(
43+
astViewer,
44+
astTemplateProvider,
45+
progress,
46+
token,
47+
selectedFile,
48+
),
49+
{
50+
cancellable: true,
51+
title: "Calculate AST",
52+
},
5053
);
5154

52-
const viewCfgCommand = async (
53-
progress: ProgressCallback,
54-
token: CancellationToken,
55-
) => {
56-
const res = await cfgTemplateProvider.provideCfgUri(
57-
window.activeTextEditor?.document,
55+
const viewCfgCommand = async () =>
56+
withProgress(
57+
async (progress, token) => {
58+
const res = await cfgTemplateProvider.provideCfgUri(
59+
window.activeTextEditor?.document,
60+
);
61+
if (res) {
62+
await compileAndRunQuery(
63+
queryRunner,
64+
queryHistoryManager,
65+
databaseUI,
66+
localQueryResultsView,
67+
queryStorageDir,
68+
false,
69+
res[0],
70+
progress,
71+
token,
72+
undefined,
73+
);
74+
}
75+
},
76+
{
77+
title: "Calculating Control Flow Graph",
78+
cancellable: true,
79+
},
5880
);
59-
if (res) {
60-
await compileAndRunQuery(
61-
queryRunner,
62-
queryHistoryManager,
63-
databaseUI,
64-
localQueryResultsView,
65-
queryStorageDir,
66-
false,
67-
res[0],
68-
progress,
69-
token,
70-
undefined,
71-
);
72-
}
73-
};
7481

75-
ctx.subscriptions.push(
76-
commandRunnerWithProgress("codeQL.viewAst", viewAstCommand, {
77-
cancellable: true,
78-
title: "Calculate AST",
79-
}),
80-
);
82+
ctx.subscriptions.push(commandRunner("codeQL.viewAst", viewAstCommand));
8183

8284
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
8385
ctx.subscriptions.push(
84-
commandRunnerWithProgress("codeQL.viewAstContextExplorer", viewAstCommand, {
85-
cancellable: true,
86-
title: "Calculate AST",
87-
}),
86+
commandRunner("codeQL.viewAstContextExplorer", viewAstCommand),
8887
);
8988

9089
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
9190
ctx.subscriptions.push(
92-
commandRunnerWithProgress("codeQL.viewAstContextEditor", viewAstCommand, {
93-
cancellable: true,
94-
title: "Calculate AST",
95-
}),
91+
commandRunner("codeQL.viewAstContextEditor", viewAstCommand),
9692
);
9793

98-
ctx.subscriptions.push(
99-
commandRunnerWithProgress("codeQL.viewCfg", viewCfgCommand, {
100-
title: "Calculating Control Flow Graph",
101-
cancellable: true,
102-
}),
103-
);
94+
ctx.subscriptions.push(commandRunner("codeQL.viewCfg", viewCfgCommand));
10495

10596
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command
10697
ctx.subscriptions.push(
107-
commandRunnerWithProgress("codeQL.viewCfgContextExplorer", viewCfgCommand, {
108-
title: "Calculating Control Flow Graph",
109-
cancellable: true,
110-
}),
98+
commandRunner("codeQL.viewCfgContextExplorer", viewCfgCommand),
11199
);
112100

113101
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command
114102
ctx.subscriptions.push(
115-
commandRunnerWithProgress("codeQL.viewCfgContextEditor", viewCfgCommand, {
116-
title: "Calculating Control Flow Graph",
117-
cancellable: true,
118-
}),
103+
commandRunner("codeQL.viewCfgContextEditor", viewCfgCommand),
119104
);
120105
}
121106

0 commit comments

Comments
 (0)