Skip to content

Show system items in ObjectScript Explorer view #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@
{
"command": "vscode-objectscript.explorer.hideGenerated",
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:generated:/"
},
{
"command": "vscode-objectscript.explorer.showSystem",
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:(%SYS|system):).)*$/"
},
{
"command": "vscode-objectscript.explorer.hideSystem",
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:system:/"
}
],
"editor/context": [
Expand Down Expand Up @@ -401,6 +409,16 @@
"title": "Hide Generated",
"category": "ObjectScript"
},
{
"command": "vscode-objectscript.explorer.showSystem",
"title": "Show System",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since %Z classes aren't system classes, I suggest this menu item name be "Show % Classes"

reference: https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GORIENT_appx_identifiers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%ZEN also %Z

"category": "ObjectScript"
},
{
"command": "vscode-objectscript.explorer.hideSystem",
"title": "Hide System",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since %Z classes aren't system classes, I suggest this menu item name be "Hide % Classes"

reference: https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GORIENT_appx_identifiers

"category": "ObjectScript"
},
{
"command": "vscode-objectscript.explorer.otherNamespaceClose",
"title": "Close Namespace",
Expand Down
9 changes: 5 additions & 4 deletions src/explorer/models/nodeBase.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as vscode from "vscode";
import { config, workspaceState } from "../../extension";
import { currentWorkspaceFolder } from "../../utils";
import { AtelierAPI } from "../../api";

export interface NodeOptions {
extraNode?: boolean;
generated?: boolean;
system?: boolean;
namespace?: string;
workspaceFolder?: string;
}
Expand All @@ -28,14 +29,14 @@ export class NodeBase {
this.fullName = fullName;
const { workspaceFolder, namespace, extraNode } = options;
this.workspaceFolder = workspaceFolder || currentWorkspaceFolder();
this.conn = config("conn", workspaceFolder);
const api = new AtelierAPI(workspaceFolder);
this.conn = api.config;
this.namespace = namespace || this.conn.ns;
this.extraNode = extraNode;
}

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

public getTreeItem(): vscode.TreeItem {
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/models/rootNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class RootNode extends NodeBase {

spec = path + spec;

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

const api = new AtelierAPI(this.workspaceFolder);
api.setNamespace(this.namespace);
Expand Down
10 changes: 7 additions & 3 deletions src/explorer/models/workspaceNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ export class WorkspaceNode extends NodeBase {
public uniqueId: string;
public constructor(label: string, eventEmitter: vscode.EventEmitter<NodeBase>, options: NodeOptions) {
super(label, label, options);
this.uniqueId = `serverNode${this.extraNode ? ":extra:" + this.namespace : ""}`;
this.uniqueId = `serverNode:${this.namespace}:${this.extraNode ? ":extra:" : ""}`;
this.options.generated = workspaceState.get(`ExplorerGenerated:${this.uniqueId}`);
this.options.system = workspaceState.get(`ExplorerSystem:${this.uniqueId}`);
this.eventEmitter = eventEmitter;
}

public getTreeItem(): vscode.TreeItem {
const flags = [];
this.options.generated && flags.push(":generated:");
this.options.system && flags.push(":system:");
return {
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
contextValue: `${this.uniqueId}${this.options.generated ? ":generated:" : ""}`,
contextValue: `${this.uniqueId}${flags.join("")}`,
label: `${this.label}(${this.connInfo})`,
};
}

public async getChildren(element: NodeBase): Promise<NodeBase[]> {
public async getChildren(_element: NodeBase): Promise<NodeBase[]> {
const children = [];
let node: RootNode;

Expand Down
8 changes: 8 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
workspaceState.update(`ExplorerGenerated:${workspaceNode.uniqueId}`, true);
return explorerProvider.refresh();
}),
vscode.commands.registerCommand("vscode-objectscript.explorer.showSystem", (workspaceNode: WorkspaceNode) => {
workspaceState.update(`ExplorerSystem:${workspaceNode.uniqueId}`, true);
return explorerProvider.refresh();
}),
vscode.commands.registerCommand("vscode-objectscript.explorer.hideGenerated", (workspaceNode: WorkspaceNode) => {
workspaceState.update(`ExplorerGenerated:${workspaceNode.uniqueId}`, false);
return explorerProvider.refresh();
}),
vscode.commands.registerCommand("vscode-objectscript.explorer.hideSystem", (workspaceNode: WorkspaceNode) => {
workspaceState.update(`ExplorerSystem:${workspaceNode.uniqueId}`, false);
return explorerProvider.refresh();
}),
vscode.commands.registerCommand("vscode-objectscript.explorer.otherNamespace", (workspaceNode: WorkspaceNode) => {
return explorerProvider.selectNamespace(workspaceNode.label);
}),
Expand Down