Skip to content

Commit 0aae739

Browse files
authored
Merge pull request #2677 from github/robert-nora/set-up-model-details-view
Set up model details view
2 parents 55557df + 81294ec commit 0aae739

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

extensions/ql-vscode/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,13 @@
16551655
"title": "CodeQL",
16561656
"icon": "media/logo.svg"
16571657
}
1658+
],
1659+
"panel": [
1660+
{
1661+
"id": "codeql-model-details",
1662+
"title": "CodeQL Model Details",
1663+
"icon": "media/logo.svg"
1664+
}
16581665
]
16591666
},
16601667
"views": {
@@ -1685,9 +1692,20 @@
16851692
"name": "Evaluator Log Viewer",
16861693
"when": "config.codeQL.canary"
16871694
}
1695+
],
1696+
"codeql-model-details": [
1697+
{
1698+
"id": "codeQLModelDetails",
1699+
"name": "CodeQL Model Details",
1700+
"when": "config.codeQL.canary && config.codeQL.dataExtensions.modelDetailsView"
1701+
}
16881702
]
16891703
},
16901704
"viewsWelcome": [
1705+
{
1706+
"view": "codeQLModelDetails",
1707+
"contents": "Loading..."
1708+
},
16911709
{
16921710
"view": "codeQLAstViewer",
16931711
"contents": "Run the 'CodeQL: View AST' command on an open source file from a CodeQL database.\n[View AST](command:codeQL.viewAst)"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export type ExplorerSelectionCommandFunction<Item> = (
5858
type BuiltInVsCodeCommands = {
5959
// The codeQLDatabases.focus command is provided by VS Code because we've registered the custom view
6060
"codeQLDatabases.focus": () => Promise<void>;
61+
"codeQLModelDetails.focus": () => Promise<void>;
6162
"markdown.showPreviewToSide": (uri: Uri) => Promise<void>;
6263
"workbench.action.closeActiveEditor": () => Promise<void>;
6364
revealFileInOS: (uri: Uri) => Promise<void>;

extensions/ql-vscode/src/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,11 @@ const EXTENSIONS_DIRECTORY = new Setting(
714714
"extensionsDirectory",
715715
DATA_EXTENSIONS,
716716
);
717+
const MODEL_DETAILS_VIEW = new Setting("modelDetailsView", DATA_EXTENSIONS);
718+
719+
export function showModelDetailsView(): boolean {
720+
return !!MODEL_DETAILS_VIEW.getValue<boolean>();
721+
}
717722

718723
export function showLlmGeneration(): boolean {
719724
return !!LLM_GENERATION.getValue<boolean>();

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
import {
4848
enableFrameworkMode,
4949
showLlmGeneration,
50+
showModelDetailsView,
5051
useLlmGenerationV2,
5152
} from "../config";
5253
import { getAutoModelUsages } from "./auto-model-usages-query";
@@ -138,7 +139,7 @@ export class DataExtensionsEditorView extends AbstractWebview<
138139

139140
break;
140141
case "jumpToUsage":
141-
await this.jumpToUsage(msg.location);
142+
await this.handleJumpToUsage(msg.location);
142143

143144
break;
144145
case "saveModeledMethods":
@@ -211,6 +212,18 @@ export class DataExtensionsEditorView extends AbstractWebview<
211212
});
212213
}
213214

215+
protected async handleJumpToUsage(location: ResolvableLocationValue) {
216+
if (showModelDetailsView()) {
217+
await this.openModelDetailsView();
218+
} else {
219+
await this.jumpToUsage(location);
220+
}
221+
}
222+
223+
protected async openModelDetailsView() {
224+
await this.app.commands.execute("codeQLModelDetails.focus");
225+
}
226+
214227
protected async jumpToUsage(
215228
location: ResolvableLocationValue,
216229
): Promise<void> {

0 commit comments

Comments
 (0)