Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions extensions/ql-vscode/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export type BuiltInVsCodeCommands = {
"workbench.action.reloadWindow": () => Promise<void>;
};

// Commands that are available before the extension is fully activated.
// These commands are *not* registered using the command manager, but can
// be invoked using the command manager.
export type PreActivationCommands = {
"codeQL.checkForUpdatesToCLI": () => Promise<void>;
};

// Base commands not tied directly to a module like e.g. variant analysis.
export type BaseCommands = {
"codeQL.openDocumentation": () => Promise<void>;
Expand Down Expand Up @@ -237,7 +244,7 @@ export type MockGitHubApiServerCommands = {
"codeQL.mockGitHubApiServer.unloadScenario": () => Promise<void>;
};

// All commands where the implementation is provided by this extension.
// All commands where the implementation is provided by this activated extension.
export type AllExtensionCommands = BaseCommands &
QueryEditorCommands &
ResultsViewCommands &
Expand All @@ -253,7 +260,9 @@ export type AllExtensionCommands = BaseCommands &
Partial<TestUICommands> &
MockGitHubApiServerCommands;

export type AllCommands = AllExtensionCommands & BuiltInVsCodeCommands;
export type AllCommands = AllExtensionCommands &
PreActivationCommands &
BuiltInVsCodeCommands;

export type AppCommandManager = CommandManager<AllCommands>;

Expand Down
8 changes: 7 additions & 1 deletion extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import { QueryHistoryDirs } from "./query-history/query-history-dirs";
import {
AllExtensionCommands,
BaseCommands,
PreActivationCommands,
QueryServerCommands,
TestUICommands,
} from "./common/commands";
Expand Down Expand Up @@ -204,6 +205,8 @@ function registerErrorStubs(

stubbedCommands.forEach((command) => {
if (excludedCommands.indexOf(command) === -1) {
// This is purposefully using `commandRunner` instead of the command manager because these
// commands are untyped and registered pre-activation.
errorStubs.push(commandRunner(command, stubGenerator(command)));
}
});
Expand Down Expand Up @@ -305,6 +308,8 @@ export async function activate(
),
);
ctx.subscriptions.push(
// This is purposefully using `commandRunner` directly instead of the command manager
// because this command is registered pre-activation.
commandRunner(checkForUpdatesCommand, () =>
installOrUpdateThenTryActivate(
ctx,
Expand Down Expand Up @@ -1096,7 +1101,8 @@ async function initializeLogging(ctx: ExtensionContext): Promise<void> {
ctx.subscriptions.push(ideServerLogger);
}

const checkForUpdatesCommand = "codeQL.checkForUpdatesToCLI";
const checkForUpdatesCommand: keyof PreActivationCommands =
"codeQL.checkForUpdatesToCLI" as const;

const avoidVersionCheck = "avoid-version-check-at-startup";
const lastVersionChecked = "last-version-checked";
Expand Down