|
1 | 1 | import { CancellationToken, ExtensionContext, Uri, window } from "vscode"; |
2 | | -import { commandRunnerWithProgress, ProgressCallback } from "./commandRunner"; |
| 2 | +import { commandRunner, ProgressCallback, withProgress } from "./commandRunner"; |
3 | 3 | import { AstViewer } from "./astViewer"; |
4 | 4 | import { |
5 | 5 | TemplatePrintAstProvider, |
@@ -36,86 +36,71 @@ export function registerAstCfgCommands( |
36 | 36 | cfgTemplateProvider, |
37 | 37 | }: AstCfgOptions, |
38 | 38 | ) { |
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 | + }, |
50 | 53 | ); |
51 | 54 |
|
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 | + }, |
58 | 80 | ); |
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 | | - }; |
74 | 81 |
|
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)); |
81 | 83 |
|
82 | 84 | // Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command |
83 | 85 | ctx.subscriptions.push( |
84 | | - commandRunnerWithProgress("codeQL.viewAstContextExplorer", viewAstCommand, { |
85 | | - cancellable: true, |
86 | | - title: "Calculate AST", |
87 | | - }), |
| 86 | + commandRunner("codeQL.viewAstContextExplorer", viewAstCommand), |
88 | 87 | ); |
89 | 88 |
|
90 | 89 | // Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command |
91 | 90 | ctx.subscriptions.push( |
92 | | - commandRunnerWithProgress("codeQL.viewAstContextEditor", viewAstCommand, { |
93 | | - cancellable: true, |
94 | | - title: "Calculate AST", |
95 | | - }), |
| 91 | + commandRunner("codeQL.viewAstContextEditor", viewAstCommand), |
96 | 92 | ); |
97 | 93 |
|
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)); |
104 | 95 |
|
105 | 96 | // Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command |
106 | 97 | ctx.subscriptions.push( |
107 | | - commandRunnerWithProgress("codeQL.viewCfgContextExplorer", viewCfgCommand, { |
108 | | - title: "Calculating Control Flow Graph", |
109 | | - cancellable: true, |
110 | | - }), |
| 98 | + commandRunner("codeQL.viewCfgContextExplorer", viewCfgCommand), |
111 | 99 | ); |
112 | 100 |
|
113 | 101 | // Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command |
114 | 102 | ctx.subscriptions.push( |
115 | | - commandRunnerWithProgress("codeQL.viewCfgContextEditor", viewCfgCommand, { |
116 | | - title: "Calculating Control Flow Graph", |
117 | | - cancellable: true, |
118 | | - }), |
| 103 | + commandRunner("codeQL.viewCfgContextEditor", viewCfgCommand), |
119 | 104 | ); |
120 | 105 | } |
121 | 106 |
|
|
0 commit comments