Convert AST viewer commands to typed commands
This commit is contained in:
@@ -23,11 +23,11 @@ import {
|
|||||||
isWholeFileLoc,
|
isWholeFileLoc,
|
||||||
isLineColumnLoc,
|
isLineColumnLoc,
|
||||||
} from "./pure/bqrs-utils";
|
} from "./pure/bqrs-utils";
|
||||||
import { commandRunner } from "./commandRunner";
|
|
||||||
import { DisposableObject } from "./pure/disposable-object";
|
import { DisposableObject } from "./pure/disposable-object";
|
||||||
import { showAndLogExceptionWithTelemetry } from "./helpers";
|
import { showAndLogExceptionWithTelemetry } from "./helpers";
|
||||||
import { asError, getErrorMessage } from "./pure/helpers-pure";
|
import { asError, getErrorMessage } from "./pure/helpers-pure";
|
||||||
import { redactableError } from "./pure/errors";
|
import { redactableError } from "./pure/errors";
|
||||||
|
import { AstViewerCommands } from "./common/commands";
|
||||||
|
|
||||||
export interface AstItem {
|
export interface AstItem {
|
||||||
id: BqrsId;
|
id: BqrsId;
|
||||||
@@ -55,15 +55,6 @@ class AstViewerDataProvider
|
|||||||
readonly onDidChangeTreeData: Event<AstItem | undefined> =
|
readonly onDidChangeTreeData: Event<AstItem | undefined> =
|
||||||
this._onDidChangeTreeData.event;
|
this._onDidChangeTreeData.event;
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.push(
|
|
||||||
commandRunner("codeQLAstViewer.gotoCode", async (item: AstItem) => {
|
|
||||||
await showLocation(item.fileLocation);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh(): void {
|
refresh(): void {
|
||||||
this._onDidChangeTreeData.fire(undefined);
|
this._onDidChangeTreeData.fire(undefined);
|
||||||
}
|
}
|
||||||
@@ -126,16 +117,20 @@ export class AstViewer extends DisposableObject {
|
|||||||
|
|
||||||
this.push(this.treeView);
|
this.push(this.treeView);
|
||||||
this.push(this.treeDataProvider);
|
this.push(this.treeDataProvider);
|
||||||
this.push(
|
|
||||||
commandRunner("codeQLAstViewer.clear", async () => {
|
|
||||||
this.clear();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
this.push(
|
this.push(
|
||||||
window.onDidChangeTextEditorSelection(this.updateTreeSelection, this),
|
window.onDidChangeTextEditorSelection(this.updateTreeSelection, this),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCommands(): AstViewerCommands {
|
||||||
|
return {
|
||||||
|
"codeQLAstViewer.clear": async () => this.clear(),
|
||||||
|
"codeQLAstViewer.gotoCode": async (item: AstItem) => {
|
||||||
|
await showLocation(item.fileLocation);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
updateRoots(roots: AstItem[], db: DatabaseItem, fileUri: Uri) {
|
updateRoots(roots: AstItem[], db: DatabaseItem, fileUri: Uri) {
|
||||||
this.treeDataProvider.roots = roots;
|
this.treeDataProvider.roots = roots;
|
||||||
this.treeDataProvider.db = db;
|
this.treeDataProvider.db = db;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { CommandManager } from "../packages/commands";
|
import type { CommandManager } from "../packages/commands";
|
||||||
import type { Uri, Range } from "vscode";
|
import type { Uri, Range } from "vscode";
|
||||||
|
import type { AstItem } from "../astViewer";
|
||||||
import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
|
import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
|
||||||
import type { DatabaseItem } from "../local-databases";
|
import type { DatabaseItem } from "../local-databases";
|
||||||
import type { QueryHistoryInfo } from "../query-history/query-history-info";
|
import type { QueryHistoryInfo } from "../query-history/query-history-info";
|
||||||
@@ -176,6 +177,11 @@ export type AstCfgCommands = {
|
|||||||
"codeQL.viewCfgContextEditor": () => Promise<void>;
|
"codeQL.viewCfgContextEditor": () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type AstViewerCommands = {
|
||||||
|
"codeQLAstViewer.clear": () => Promise<void>;
|
||||||
|
"codeQLAstViewer.gotoCode": (item: AstItem) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
export type PackagingCommands = {
|
export type PackagingCommands = {
|
||||||
"codeQL.installPackDependencies": () => Promise<void>;
|
"codeQL.installPackDependencies": () => Promise<void>;
|
||||||
"codeQL.downloadPacks": () => Promise<void>;
|
"codeQL.downloadPacks": () => Promise<void>;
|
||||||
@@ -191,6 +197,7 @@ export type AllCommands = BaseCommands &
|
|||||||
VariantAnalysisCommands &
|
VariantAnalysisCommands &
|
||||||
DatabasePanelCommands &
|
DatabasePanelCommands &
|
||||||
AstCfgCommands &
|
AstCfgCommands &
|
||||||
|
AstViewerCommands &
|
||||||
PackagingCommands &
|
PackagingCommands &
|
||||||
EvalLogViewerCommands;
|
EvalLogViewerCommands;
|
||||||
|
|
||||||
|
|||||||
@@ -837,6 +837,7 @@ async function activateWithInstalledDistribution(
|
|||||||
astTemplateProvider,
|
astTemplateProvider,
|
||||||
cfgTemplateProvider,
|
cfgTemplateProvider,
|
||||||
}),
|
}),
|
||||||
|
...astViewer.getCommands(),
|
||||||
...getPackagingCommands({
|
...getPackagingCommands({
|
||||||
cliServer,
|
cliServer,
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user