Skip to content

Commit df86adb

Browse files
committed
Split variant analysis and extension commands
1 parent e97ffd2 commit df86adb

3 files changed

Lines changed: 20 additions & 25 deletions

File tree

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { CommandManager } from "../packages/commands";
22

33
export type ExtensionCommands = {
4+
"codeQL.openDocumentation": () => Promise<void>;
5+
};
6+
7+
export type VariantAnalysisCommands = {
48
"codeQL.openVariantAnalysisLogs": (
59
variantAnalysisId: number,
610
) => Promise<void>;
711
};
812

9-
export type AllCommands = ExtensionCommands;
13+
export type AllCommands = ExtensionCommands & VariantAnalysisCommands;
1014

1115
export type ExtensionCommandManager = CommandManager<AllCommands>;

extensions/ql-vscode/src/extension.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,10 @@ let isInstallingOrUpdatingDistribution = false;
169169
const extensionId = "GitHub.vscode-codeql";
170170
const extension = extensions.getExtension(extensionId);
171171

172-
function getCommands(
173-
variantAnalysisManager: VariantAnalysisManager,
174-
): ExtensionCommands {
172+
function getCommands(): ExtensionCommands {
175173
return {
176-
"codeQL.openVariantAnalysisLogs": async (variantAnalysisId: number) => {
177-
await variantAnalysisManager.openVariantAnalysisLogs(variantAnalysisId);
174+
"codeQL.openDocumentation": async () => {
175+
await env.openExternal(Uri.parse("https://codeql.github.com/docs/"));
178176
},
179177
};
180178
}
@@ -1164,19 +1162,9 @@ async function activateWithInstalledDistribution(
11641162
),
11651163
);
11661164

1167-
/*
1168-
ctx.subscriptions.push(
1169-
commandRunner(
1170-
"codeQL.openVariantAnalysisLogs",
1171-
async (variantAnalysisId: number) => {
1172-
await variantAnalysisManager.openVariantAnalysisLogs(variantAnalysisId);
1173-
},
1174-
),
1175-
);
1176-
*/
1177-
1178-
const allCommands: Partial<AllCommands> = {
1179-
...getCommands(variantAnalysisManager),
1165+
const allCommands: AllCommands = {
1166+
...getCommands(),
1167+
...variantAnalysisManager.getCommands(),
11801168
};
11811169

11821170
for (const [commandName, command] of Object.entries(allCommands)) {
@@ -1383,12 +1371,6 @@ async function activateWithInstalledDistribution(
13831371
),
13841372
);
13851373

1386-
ctx.subscriptions.push(
1387-
commandRunner("codeQL.openDocumentation", async () =>
1388-
env.openExternal(Uri.parse("https://codeql.github.com/docs/")),
1389-
),
1390-
);
1391-
13921374
ctx.subscriptions.push(
13931375
commandRunner("codeQL.copyVersion", async () => {
13941376
const text = `CodeQL extension version: ${

extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { URLSearchParams } from "url";
6262
import { DbManager } from "../databases/db-manager";
6363
import { App } from "../common/app";
6464
import { redactableError } from "../pure/errors";
65+
import { VariantAnalysisCommands } from "../common/commands";
6566

6667
export class VariantAnalysisManager
6768
extends DisposableObject
@@ -123,6 +124,14 @@ export class VariantAnalysisManager
123124
);
124125
}
125126

127+
getCommands(): VariantAnalysisCommands {
128+
return {
129+
"codeQL.openVariantAnalysisLogs": async (variantAnalysisId: number) => {
130+
await this.openVariantAnalysisLogs(variantAnalysisId);
131+
},
132+
};
133+
}
134+
126135
public async runVariantAnalysis(
127136
uri: Uri | undefined,
128137
progress: ProgressCallback,

0 commit comments

Comments
 (0)