Only include method signature in JumpToUsageMessage
This commit is contained in:
@@ -12,7 +12,6 @@ import type {
|
||||
} from "../variant-analysis/shared/variant-analysis";
|
||||
import type { QLDebugConfiguration } from "../debugger/debug-configuration";
|
||||
import type { QueryTreeViewItem } from "../queries-panel/query-tree-view-item";
|
||||
import type { Method, Usage } from "../model-editor/method";
|
||||
|
||||
// A command function matching the signature that VS Code calls when
|
||||
// a command is invoked from a context menu on a TreeView with
|
||||
@@ -325,8 +324,7 @@ export type ModelEditorCommands = {
|
||||
"codeQL.openModelEditor": () => Promise<void>;
|
||||
"codeQL.openModelEditorFromModelingPanel": () => Promise<void>;
|
||||
"codeQLModelEditor.jumpToUsageLocation": (
|
||||
method: Method,
|
||||
usage: Usage,
|
||||
methodSignature: string,
|
||||
databaseItem: DatabaseItem,
|
||||
) => Promise<void>;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from "../variant-analysis/shared/variant-analysis-filter-sort";
|
||||
import { ErrorLike } from "../common/errors";
|
||||
import { DataFlowPaths } from "../variant-analysis/shared/data-flow-paths";
|
||||
import { Method, Usage } from "../model-editor/method";
|
||||
import { Method } from "../model-editor/method";
|
||||
import { ModeledMethod } from "../model-editor/modeled-method";
|
||||
import {
|
||||
MethodModelingPanelViewState,
|
||||
@@ -528,8 +528,7 @@ interface SwitchModeMessage {
|
||||
|
||||
interface JumpToUsageMessage {
|
||||
t: "jumpToUsage";
|
||||
method: Method;
|
||||
usage: Usage;
|
||||
methodSignature: string;
|
||||
}
|
||||
|
||||
interface OpenDatabaseMessage {
|
||||
|
||||
@@ -83,6 +83,9 @@ export class MethodsUsageDataProvider
|
||||
};
|
||||
} else {
|
||||
const method = this.getParent(item);
|
||||
if (!method || !isExternalApiUsage(method)) {
|
||||
throw new Error("Parent not found for tree item");
|
||||
}
|
||||
return {
|
||||
label: item.label,
|
||||
description: `${this.relativePathWithinDatabase(item.url.uri)} [${
|
||||
@@ -92,7 +95,7 @@ export class MethodsUsageDataProvider
|
||||
command: {
|
||||
title: "Show usage",
|
||||
command: "codeQLModelEditor.jumpToUsageLocation",
|
||||
arguments: [method, item, this.databaseItem],
|
||||
arguments: [method.signature, this.databaseItem],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -78,11 +78,10 @@ export class ModelEditorModule extends DisposableObject {
|
||||
"codeQL.openModelEditorFromModelingPanel":
|
||||
this.openModelEditor.bind(this),
|
||||
"codeQLModelEditor.jumpToUsageLocation": async (
|
||||
method: Method,
|
||||
usage: Usage,
|
||||
methodSignature: string,
|
||||
databaseItem: DatabaseItem,
|
||||
) => {
|
||||
this.modelingStore.setSelectedMethod(databaseItem, method, usage);
|
||||
this.modelingStore.setSelectedMethod(databaseItem, methodSignature);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
externalApiQueriesProgressMaxStep,
|
||||
runExternalApiQueries,
|
||||
} from "./external-api-usage-queries";
|
||||
import { Method, Usage } from "./method";
|
||||
import { Method } from "./method";
|
||||
import { ModeledMethod } from "./modeled-method";
|
||||
import { ExtensionPack } from "./shared/extension-pack";
|
||||
import { ModelConfigListener } from "../config";
|
||||
@@ -198,7 +198,7 @@ export class ModelEditorView extends AbstractWebview<
|
||||
|
||||
break;
|
||||
case "jumpToUsage":
|
||||
await this.handleJumpToUsage(msg.method, msg.usage);
|
||||
await this.handleJumpToUsage(msg.methodSignature);
|
||||
void telemetryListener?.sendUIInteraction("model-editor-jump-to-usage");
|
||||
|
||||
break;
|
||||
@@ -361,8 +361,8 @@ export class ModelEditorView extends AbstractWebview<
|
||||
});
|
||||
}
|
||||
|
||||
protected async handleJumpToUsage(method: Method, usage: Usage) {
|
||||
this.modelingStore.setSelectedMethod(this.databaseItem, method, usage);
|
||||
protected async handleJumpToUsage(methodSignature: string) {
|
||||
this.modelingStore.setSelectedMethod(this.databaseItem, methodSignature);
|
||||
}
|
||||
|
||||
protected async loadExistingModeledMethods(): Promise<void> {
|
||||
|
||||
@@ -306,9 +306,18 @@ export class ModelingStore extends DisposableObject {
|
||||
});
|
||||
}
|
||||
|
||||
public setSelectedMethod(dbItem: DatabaseItem, method: Method, usage: Usage) {
|
||||
public setSelectedMethod(dbItem: DatabaseItem, methodSignature: string) {
|
||||
const dbState = this.getState(dbItem);
|
||||
|
||||
const method = dbState.methods.find((m) => m.signature === methodSignature);
|
||||
if (method === undefined) {
|
||||
throw new Error(
|
||||
`No method with signature "${methodSignature}" found in modeling store`,
|
||||
);
|
||||
}
|
||||
|
||||
const usage = method.usages[0];
|
||||
|
||||
dbState.selectedMethod = method;
|
||||
dbState.selectedUsage = usage;
|
||||
|
||||
|
||||
@@ -213,8 +213,6 @@ UnmodelableMethodRow.displayName = "UnmodelableMethodRow";
|
||||
function sendJumpToUsageMessage(method: Method) {
|
||||
vscode.postMessage({
|
||||
t: "jumpToUsage",
|
||||
method,
|
||||
// In framework mode, the first and only usage is the definition of the method
|
||||
usage: method.usages[0],
|
||||
methodSignature: method.signature,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user