Skip to content

Commit 9466070

Browse files
Add command to jump to usage location
1 parent f4d6990 commit 9466070

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

extensions/ql-vscode/src/common/commands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
} from "../variant-analysis/shared/variant-analysis";
1313
import type { QLDebugConfiguration } from "../debugger/debug-configuration";
1414
import type { QueryTreeViewItem } from "../queries-panel/query-tree-view-item";
15+
import type { Usage } from "../data-extensions-editor/external-api-usage";
1516

1617
// A command function matching the signature that VS Code calls when
1718
// a command is invoked from a context menu on a TreeView with
@@ -304,6 +305,10 @@ export type PackagingCommands = {
304305

305306
export type DataExtensionsEditorCommands = {
306307
"codeQL.openDataExtensionsEditor": () => Promise<void>;
308+
"codeQLDataExtensions.jumpToUsageLocation": (
309+
usage: Usage,
310+
databaseItem: DatabaseItem,
311+
) => Promise<void>;
307312
};
308313

309314
export type EvalLogViewerCommands = {

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DataExtensionsEditorView } from "./data-extensions-editor-view";
33
import { DataExtensionsEditorCommands } from "../common/commands";
44
import { CliVersionConstraint, CodeQLCliServer } from "../codeql-cli/cli";
55
import { QueryRunner } from "../query-server";
6-
import { DatabaseManager } from "../databases/local-databases";
6+
import { DatabaseItem, DatabaseManager } from "../databases/local-databases";
77
import { ensureDir } from "fs-extra";
88
import { join } from "path";
99
import { App } from "../common/app";
@@ -23,6 +23,8 @@ import { setUpPack } from "./external-api-usage-query";
2323
import { DisposableObject } from "../common/disposable-object";
2424
import { ModelDetailsPanel } from "./model-details/model-details-panel";
2525
import { Mode } from "./shared/mode";
26+
import { showResolvableLocation } from "../databases/local-databases/locations";
27+
import { Usage } from "./external-api-usage";
2628

2729
const SUPPORTED_LANGUAGES: string[] = ["java", "csharp"];
2830

@@ -154,6 +156,12 @@ export class DataExtensionsEditorModule extends DisposableObject {
154156
},
155157
);
156158
},
159+
"codeQLDataExtensions.jumpToUsageLocation": async (
160+
usage: Usage,
161+
databaseItem: DatabaseItem,
162+
) => {
163+
await showResolvableLocation(usage.url, databaseItem, this.app.logger);
164+
},
157165
};
158166
}
159167

extensions/ql-vscode/test/unit-tests/command-lint.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ describe("commands declared in package.json", () => {
4444
command.match(/^codeQLQueryHistory\./) ||
4545
command.match(/^codeQLAstViewer\./) ||
4646
command.match(/^codeQLEvalLogViewer\./) ||
47-
command.match(/^codeQLTests\./)
47+
command.match(/^codeQLTests\./) ||
48+
command.match(/^codeQLDataExtensions\./)
4849
) {
4950
scopedCmds.add(command);
5051
expect(title).toBeDefined();

0 commit comments

Comments
 (0)