Skip to content

Commit 17bab1c

Browse files
committed
Remove unnecessary viewAst function
1 parent b3092be commit 17bab1c

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

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

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CancellationToken, Uri, window } from "vscode";
2-
import { ProgressCallback, withProgress } from "./commandRunner";
1+
import { Uri, window } from "vscode";
2+
import { withProgress } from "./commandRunner";
33
import { AstViewer } from "./astViewer";
44
import {
55
TemplatePrintAstProvider,
@@ -34,23 +34,25 @@ export function getAstCfgCommands({
3434
astTemplateProvider,
3535
cfgTemplateProvider,
3636
}: AstCfgOptions): AstCfgCommands {
37-
const viewAstCommand = async (selectedFile: Uri) =>
37+
const viewAst = async (selectedFile: Uri) =>
3838
withProgress(
39-
async (progress, token) =>
40-
await viewAst(
41-
astViewer,
42-
astTemplateProvider,
39+
async (progress, token) => {
40+
const ast = await astTemplateProvider.provideAst(
4341
progress,
4442
token,
45-
selectedFile,
46-
),
43+
selectedFile ?? window.activeTextEditor?.document.uri,
44+
);
45+
if (ast) {
46+
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
47+
}
48+
},
4749
{
4850
cancellable: true,
4951
title: "Calculate AST",
5052
},
5153
);
5254

53-
const viewCfgCommand = async () =>
55+
const viewCfg = async () =>
5456
withProgress(
5557
async (progress, token) => {
5658
const res = await cfgTemplateProvider.provideCfgUri(
@@ -78,28 +80,11 @@ export function getAstCfgCommands({
7880
);
7981

8082
return {
81-
"codeQL.viewAst": viewAstCommand,
82-
"codeQL.viewAstContextExplorer": viewAstCommand,
83-
"codeQL.viewAstContextEditor": viewAstCommand,
84-
"codeQL.viewCfg": viewCfgCommand,
85-
"codeQL.viewCfgContextExplorer": viewCfgCommand,
86-
"codeQL.viewCfgContextEditor": viewCfgCommand,
83+
"codeQL.viewAst": viewAst,
84+
"codeQL.viewAstContextExplorer": viewAst,
85+
"codeQL.viewAstContextEditor": viewAst,
86+
"codeQL.viewCfg": viewCfg,
87+
"codeQL.viewCfgContextExplorer": viewCfg,
88+
"codeQL.viewCfgContextEditor": viewCfg,
8789
};
8890
}
89-
90-
async function viewAst(
91-
astViewer: AstViewer,
92-
printAstTemplateProvider: TemplatePrintAstProvider,
93-
progress: ProgressCallback,
94-
token: CancellationToken,
95-
selectedFile: Uri,
96-
): Promise<void> {
97-
const ast = await printAstTemplateProvider.provideAst(
98-
progress,
99-
token,
100-
selectedFile ?? window.activeTextEditor?.document.uri,
101-
);
102-
if (ast) {
103-
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
104-
}
105-
}

0 commit comments

Comments
 (0)