Skip to content

Commit 24f51fc

Browse files
authored
Merge pull request #189 from intersystems-community/#165-explorer_show_system
Show system items in ObjectScript Explorer view
2 parents e136337 + 908ed7c commit 24f51fc

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@
193193
{
194194
"command": "vscode-objectscript.explorer.hideGenerated",
195195
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:generated:/"
196+
},
197+
{
198+
"command": "vscode-objectscript.explorer.showSystem",
199+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:(%SYS|system):).)*$/"
200+
},
201+
{
202+
"command": "vscode-objectscript.explorer.hideSystem",
203+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:system:/"
196204
}
197205
],
198206
"editor/context": [
@@ -402,6 +410,16 @@
402410
"title": "Hide Generated",
403411
"category": "ObjectScript"
404412
},
413+
{
414+
"command": "vscode-objectscript.explorer.showSystem",
415+
"title": "Show System",
416+
"category": "ObjectScript"
417+
},
418+
{
419+
"command": "vscode-objectscript.explorer.hideSystem",
420+
"title": "Hide System",
421+
"category": "ObjectScript"
422+
},
405423
{
406424
"command": "vscode-objectscript.explorer.otherNamespaceClose",
407425
"title": "Close Namespace",

src/explorer/models/nodeBase.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as vscode from "vscode";
2-
import { config, workspaceState } from "../../extension";
32
import { currentWorkspaceFolder } from "../../utils";
3+
import { AtelierAPI } from "../../api";
44

55
export interface NodeOptions {
66
extraNode?: boolean;
77
generated?: boolean;
8+
system?: boolean;
89
namespace?: string;
910
workspaceFolder?: string;
1011
}
@@ -28,14 +29,14 @@ export class NodeBase {
2829
this.fullName = fullName;
2930
const { workspaceFolder, namespace, extraNode } = options;
3031
this.workspaceFolder = workspaceFolder || currentWorkspaceFolder();
31-
this.conn = config("conn", workspaceFolder);
32+
const api = new AtelierAPI(workspaceFolder);
33+
this.conn = api.config;
3234
this.namespace = namespace || this.conn.ns;
3335
this.extraNode = extraNode;
3436
}
3537

3638
public get connInfo(): string {
37-
const port = workspaceState.get(this.workspaceFolder + ":port", this.conn.port);
38-
return `${this.conn.host}:${port}[${this.namespace}]`;
39+
return `${this.conn.host}:${this.conn.port}[${this.namespace}]`;
3940
}
4041

4142
public getTreeItem(): vscode.TreeItem {

src/explorer/models/rootNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class RootNode extends NodeBase {
7676

7777
spec = path + spec;
7878

79-
const systemFiles = this.namespace === "%SYS" ? "1" : "0";
79+
const systemFiles = this.options.system || this.namespace === "%SYS" ? "1" : "0";
8080

8181
const api = new AtelierAPI(this.workspaceFolder);
8282
api.setNamespace(this.namespace);

src/explorer/models/workspaceNode.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,24 @@ export class WorkspaceNode extends NodeBase {
99
public uniqueId: string;
1010
public constructor(label: string, eventEmitter: vscode.EventEmitter<NodeBase>, options: NodeOptions) {
1111
super(label, label, options);
12-
this.uniqueId = `serverNode${this.extraNode ? ":extra:" + this.namespace : ""}`;
12+
this.uniqueId = `serverNode:${this.namespace}:${this.extraNode ? ":extra:" : ""}`;
1313
this.options.generated = workspaceState.get(`ExplorerGenerated:${this.uniqueId}`);
14+
this.options.system = workspaceState.get(`ExplorerSystem:${this.uniqueId}`);
1415
this.eventEmitter = eventEmitter;
1516
}
1617

1718
public getTreeItem(): vscode.TreeItem {
19+
const flags = [];
20+
this.options.generated && flags.push(":generated:");
21+
this.options.system && flags.push(":system:");
1822
return {
1923
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
20-
contextValue: `${this.uniqueId}${this.options.generated ? ":generated:" : ""}`,
24+
contextValue: `${this.uniqueId}${flags.join("")}`,
2125
label: `${this.label}(${this.connInfo})`,
2226
};
2327
}
2428

25-
public async getChildren(element: NodeBase): Promise<NodeBase[]> {
29+
public async getChildren(_element: NodeBase): Promise<NodeBase[]> {
2630
const children = [];
2731
let node: RootNode;
2832

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
491491
workspaceState.update(`ExplorerGenerated:${workspaceNode.uniqueId}`, true);
492492
return explorerProvider.refresh();
493493
}),
494+
vscode.commands.registerCommand("vscode-objectscript.explorer.showSystem", (workspaceNode: WorkspaceNode) => {
495+
workspaceState.update(`ExplorerSystem:${workspaceNode.uniqueId}`, true);
496+
return explorerProvider.refresh();
497+
}),
494498
vscode.commands.registerCommand("vscode-objectscript.explorer.hideGenerated", (workspaceNode: WorkspaceNode) => {
495499
workspaceState.update(`ExplorerGenerated:${workspaceNode.uniqueId}`, false);
496500
return explorerProvider.refresh();
497501
}),
502+
vscode.commands.registerCommand("vscode-objectscript.explorer.hideSystem", (workspaceNode: WorkspaceNode) => {
503+
workspaceState.update(`ExplorerSystem:${workspaceNode.uniqueId}`, false);
504+
return explorerProvider.refresh();
505+
}),
498506
vscode.commands.registerCommand("vscode-objectscript.explorer.otherNamespace", (workspaceNode: WorkspaceNode) => {
499507
return explorerProvider.selectNamespace(workspaceNode.label);
500508
}),

0 commit comments

Comments
 (0)