Skip to content

Commit 2d033bf

Browse files
authored
Update jump to usage to include the method (#2773)
1 parent 1861692 commit 2d033bf

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

extensions/ql-vscode/src/common/interface-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ interface SwitchModeMessage {
523523

524524
interface JumpToUsageMessage {
525525
t: "jumpToUsage";
526+
method: ExternalApiUsage;
526527
usage: Usage;
527528
}
528529

extensions/ql-vscode/src/model-editor/methods-usage/methods-usage-data-provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class MethodsUsageDataProvider
7171
iconPath: new ThemeIcon("symbol-method"),
7272
};
7373
} else {
74+
const method = this.getParent(item);
7475
return {
7576
label: item.label,
7677
description: `${this.relativePathWithinDatabase(item.url.uri)} [${
@@ -80,7 +81,7 @@ export class MethodsUsageDataProvider
8081
command: {
8182
title: "Show usage",
8283
command: "codeQLModelEditor.jumpToUsageLocation",
83-
arguments: [item, this.databaseItem],
84+
arguments: [method, item, this.databaseItem],
8485
},
8586
iconPath: new ThemeIcon("error", new ThemeColor("errorForeground")),
8687
};

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,23 +175,11 @@ export class ModelEditorModule extends DisposableObject {
175175
await ensureDir(this.queryStorageDir);
176176
}
177177

178-
private async showMethod(usage: Usage): Promise<void> {
178+
private async showMethod(
179+
method: ExternalApiUsage,
180+
usage: Usage,
181+
): Promise<void> {
179182
await this.methodsUsagePanel.revealItem(usage);
180-
181-
// For now, just construct a dummy method and show it in the method modeling panel
182-
// because the method isn't easily accessible yet.
183-
const method: ExternalApiUsage = {
184-
library: "sql2o",
185-
libraryVersion: "1.6.0",
186-
signature: "org.sql2o.Connection#createQuery(String)",
187-
packageName: "org.sql2o",
188-
typeName: "Connection",
189-
methodName: "createQuery",
190-
methodParameters: "(String)",
191-
supported: true,
192-
supportedType: "summary",
193-
usages: [],
194-
};
195183
await this.methodModelingPanel.setMethod(method);
196184
}
197185
}

extensions/ql-vscode/src/model-editor/model-editor-view.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export class ModelEditorView extends AbstractWebview<
6565
databaseItem: DatabaseItem,
6666
hideModeledApis: boolean,
6767
) => Promise<void>,
68-
private readonly showMethod: (usage: Usage) => Promise<void>,
68+
private readonly showMethod: (
69+
method: ExternalApiUsage,
70+
usage: Usage,
71+
) => Promise<void>,
6972
private readonly handleViewBecameActive: (view: ModelEditorView) => void,
7073
private readonly handleViewWasDisposed: (view: ModelEditorView) => void,
7174
private readonly isMostRecentlyActiveView: (
@@ -190,7 +193,7 @@ export class ModelEditorView extends AbstractWebview<
190193

191194
break;
192195
case "jumpToUsage":
193-
await this.handleJumpToUsage(msg.usage);
196+
await this.handleJumpToUsage(msg.method, msg.usage);
194197

195198
break;
196199
case "saveModeledMethods":
@@ -267,8 +270,8 @@ export class ModelEditorView extends AbstractWebview<
267270
});
268271
}
269272

270-
protected async handleJumpToUsage(usage: Usage) {
271-
await this.showMethod(usage);
273+
protected async handleJumpToUsage(method: ExternalApiUsage, usage: Usage) {
274+
await this.showMethod(method, usage);
272275
await showResolvableLocation(usage.url, this.databaseItem, this.app.logger);
273276
}
274277

extensions/ql-vscode/src/view/model-editor/MethodRow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ function UnmodelableMethodRow(props: Props) {
314314
function sendJumpToUsageMessage(externalApiUsage: ExternalApiUsage) {
315315
vscode.postMessage({
316316
t: "jumpToUsage",
317+
method: externalApiUsage,
317318
// In framework mode, the first and only usage is the definition of the method
318319
usage: externalApiUsage.usages[0],
319320
});

0 commit comments

Comments
 (0)