Merge pull request #2204 from github/koesie10/summary-language-support-typed-commands

Convert summary language commands to typed commands
This commit is contained in:
Koen Vlaswinkel
2023-03-22 14:52:45 +01:00
committed by GitHub
3 changed files with 16 additions and 5 deletions

View File

@@ -191,6 +191,10 @@ export type EvalLogViewerCommands = {
"codeQLEvalLogViewer.clear": () => Promise<void>; "codeQLEvalLogViewer.clear": () => Promise<void>;
}; };
export type SummaryLanguageSupportCommands = {
"codeQL.gotoQL": () => Promise<void>;
};
export type AllCommands = BaseCommands & export type AllCommands = BaseCommands &
QueryHistoryCommands & QueryHistoryCommands &
LocalDatabasesCommands & LocalDatabasesCommands &
@@ -199,7 +203,8 @@ export type AllCommands = BaseCommands &
AstCfgCommands & AstCfgCommands &
AstViewerCommands & AstViewerCommands &
PackagingCommands & PackagingCommands &
EvalLogViewerCommands; EvalLogViewerCommands &
SummaryLanguageSupportCommands;
export type AppCommandManager = CommandManager<AllCommands>; export type AppCommandManager = CommandManager<AllCommands>;

View File

@@ -819,6 +819,9 @@ async function activateWithInstalledDistribution(
ctx.subscriptions.push(astViewer); ctx.subscriptions.push(astViewer);
const summaryLanguageSupport = new SummaryLanguageSupport();
ctx.subscriptions.push(summaryLanguageSupport);
void extLogger.log("Registering top-level command palette commands."); void extLogger.log("Registering top-level command palette commands.");
const allCommands: AllCommands = { const allCommands: AllCommands = {
@@ -842,6 +845,7 @@ async function activateWithInstalledDistribution(
cliServer, cliServer,
}), }),
...evalLogViewer.getCommands(), ...evalLogViewer.getCommands(),
...summaryLanguageSupport.getCommands(),
}; };
for (const [commandName, command] of Object.entries(allCommands)) { for (const [commandName, command] of Object.entries(allCommands)) {
@@ -938,8 +942,6 @@ async function activateWithInstalledDistribution(
}), }),
); );
ctx.subscriptions.push(new SummaryLanguageSupport());
void extLogger.log("Starting language server."); void extLogger.log("Starting language server.");
await client.start(); await client.start();
ctx.subscriptions.push({ ctx.subscriptions.push({

View File

@@ -13,9 +13,9 @@ import {
workspace, workspace,
} from "vscode"; } from "vscode";
import { DisposableObject } from "../pure/disposable-object"; import { DisposableObject } from "../pure/disposable-object";
import { commandRunner } from "../commandRunner";
import { extLogger } from "../common"; import { extLogger } from "../common";
import { getErrorMessage } from "../pure/helpers-pure"; import { getErrorMessage } from "../pure/helpers-pure";
import { SummaryLanguageSupportCommands } from "../common/commands";
/** A `Position` within a specified file on disk. */ /** A `Position` within a specified file on disk. */
interface PositionInFile { interface PositionInFile {
@@ -73,8 +73,12 @@ export class SummaryLanguageSupport extends DisposableObject {
this.handleDidCloseTextDocument.bind(this), this.handleDidCloseTextDocument.bind(this),
), ),
); );
}
this.push(commandRunner("codeQL.gotoQL", this.handleGotoQL.bind(this))); public getCommands(): SummaryLanguageSupportCommands {
return {
"codeQL.gotoQL": this.handleGotoQL.bind(this),
};
} }
/** /**