Skip to content

Commit 7571304

Browse files
Move viewAst to top level
1 parent 764830e commit 7571304

1 file changed

Lines changed: 41 additions & 18 deletions

File tree

extensions/ql-vscode/src/extension.ts

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,29 +1459,21 @@ async function activateWithInstalledDistribution(
14591459

14601460
ctx.subscriptions.push(astViewer);
14611461

1462-
async function viewAst(
1463-
progress: ProgressCallback,
1464-
token: CancellationToken,
1465-
selectedFile: Uri,
1466-
): Promise<void> {
1467-
const ast = await printAstTemplateProvider.provideAst(
1468-
progress,
1469-
token,
1470-
selectedFile ?? window.activeTextEditor?.document.uri,
1471-
);
1472-
if (ast) {
1473-
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
1474-
}
1475-
}
1476-
14771462
ctx.subscriptions.push(
14781463
commandRunnerWithProgress(
14791464
"codeQL.viewAst",
14801465
async (
14811466
progress: ProgressCallback,
14821467
token: CancellationToken,
14831468
selectedFile: Uri,
1484-
) => await viewAst(progress, token, selectedFile),
1469+
) =>
1470+
await viewAst(
1471+
astViewer,
1472+
printAstTemplateProvider,
1473+
progress,
1474+
token,
1475+
selectedFile,
1476+
),
14851477
{
14861478
cancellable: true,
14871479
title: "Calculate AST",
@@ -1497,7 +1489,14 @@ async function activateWithInstalledDistribution(
14971489
progress: ProgressCallback,
14981490
token: CancellationToken,
14991491
selectedFile: Uri,
1500-
) => await viewAst(progress, token, selectedFile),
1492+
) =>
1493+
await viewAst(
1494+
astViewer,
1495+
printAstTemplateProvider,
1496+
progress,
1497+
token,
1498+
selectedFile,
1499+
),
15011500
{
15021501
cancellable: true,
15031502
title: "Calculate AST",
@@ -1513,7 +1512,14 @@ async function activateWithInstalledDistribution(
15131512
progress: ProgressCallback,
15141513
token: CancellationToken,
15151514
selectedFile: Uri,
1516-
) => await viewAst(progress, token, selectedFile),
1515+
) =>
1516+
await viewAst(
1517+
astViewer,
1518+
printAstTemplateProvider,
1519+
progress,
1520+
token,
1521+
selectedFile,
1522+
),
15171523
{
15181524
cancellable: true,
15191525
title: "Calculate AST",
@@ -1898,6 +1904,23 @@ async function runVariantAnalysis(
18981904
);
18991905
}
19001906

1907+
async function viewAst(
1908+
astViewer: AstViewer,
1909+
printAstTemplateProvider: TemplatePrintAstProvider,
1910+
progress: ProgressCallback,
1911+
token: CancellationToken,
1912+
selectedFile: Uri,
1913+
): Promise<void> {
1914+
const ast = await printAstTemplateProvider.provideAst(
1915+
progress,
1916+
token,
1917+
selectedFile ?? window.activeTextEditor?.document.uri,
1918+
);
1919+
if (ast) {
1920+
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
1921+
}
1922+
}
1923+
19011924
function addUnhandledRejectionListener() {
19021925
const handler = (error: unknown) => {
19031926
// This listener will be triggered for errors from other extensions as

0 commit comments

Comments
 (0)