Skip to content

Commit ec1fda2

Browse files
Open query file on click
1 parent baea365 commit ec1fda2

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

extensions/ql-vscode/src/queries-panel/query-tree-data-provider.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ export class QueryTreeDataProvider
1717
private createTree(): QueryTreeViewItem[] {
1818
// Temporary mock data, just to populate the tree view.
1919
return [
20-
new QueryTreeViewItem("name1", "path1", []),
21-
new QueryTreeViewItem("name2", "path2", [
22-
new QueryTreeViewItem("name3", "path3", []),
23-
new QueryTreeViewItem("name4", "path4", [
24-
new QueryTreeViewItem("name5", "path5", []),
20+
new QueryTreeViewItem("custom-pack", [
21+
new QueryTreeViewItem("custom-pack/example.ql", []),
22+
]),
23+
new QueryTreeViewItem("ql", [
24+
new QueryTreeViewItem("ql/javascript", [
25+
new QueryTreeViewItem("ql/javascript/example.ql", []),
26+
]),
27+
new QueryTreeViewItem("ql/go", [
28+
new QueryTreeViewItem("ql/go/security", [
29+
new QueryTreeViewItem("ql/go/security/query1.ql", []),
30+
new QueryTreeViewItem("ql/go/security/query2.ql", []),
31+
]),
2532
]),
2633
]),
2734
];
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import * as vscode from "vscode";
2+
import { basename } from "path";
23

34
export class QueryTreeViewItem extends vscode.TreeItem {
4-
constructor(
5-
label: string,
6-
tooltip: string | undefined,
7-
public readonly children: QueryTreeViewItem[],
8-
) {
9-
super(label);
10-
this.tooltip = tooltip;
5+
constructor(path: string, public readonly children: QueryTreeViewItem[]) {
6+
super(basename(path));
7+
this.tooltip = path;
118
this.collapsibleState = this.children.length
129
? vscode.TreeItemCollapsibleState.Collapsed
1310
: vscode.TreeItemCollapsibleState.None;
11+
this.command = {
12+
title: "Open",
13+
command: "vscode.open",
14+
arguments: [vscode.Uri.file(path)],
15+
};
1416
}
1517
}

0 commit comments

Comments
 (0)