From ca2d5280a8e26125de22968492cf7a6645f2a58d Mon Sep 17 00:00:00 2001 From: Vigilans Date: Tue, 19 Nov 2019 12:01:05 +0800 Subject: [PATCH 1/3] Support description of treeitem --- src/views/dataNode.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/views/dataNode.ts b/src/views/dataNode.ts index d9624eab..22319bc0 100644 --- a/src/views/dataNode.ts +++ b/src/views/dataNode.ts @@ -13,6 +13,7 @@ export abstract class DataNode extends ExplorerNode { public getTreeItem(): TreeItem | Promise { if (this._nodeData) { const item = new TreeItem(this._nodeData.name, this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None); + item.description = this.description; item.iconPath = this.iconPath; item.command = this.command; return item; @@ -63,6 +64,10 @@ export abstract class DataNode extends ExplorerNode { return true; } + protected get description(): string | boolean { + return undefined; + } + protected abstract get iconPath(): string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon; protected abstract loadData(): Thenable; From 504ff82dbc55e4ed792ef2368d7798b575b67a38 Mon Sep 17 00:00:00 2001 From: Vigilans Date: Tue, 19 Nov 2019 12:01:48 +0800 Subject: [PATCH 2/3] Fix: HierarchicalPacageNode should reuse DataNode's method to create treeitem --- src/java/hierarchicalPackageNodeData.ts | 6 +++--- src/views/hierarchicalPackageNode.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/java/hierarchicalPackageNodeData.ts b/src/java/hierarchicalPackageNodeData.ts index 2f33eeb2..33ac4d44 100644 --- a/src/java/hierarchicalPackageNodeData.ts +++ b/src/java/hierarchicalPackageNodeData.ts @@ -18,15 +18,15 @@ export class HierarchicalPackageNodeData implements INodeData { private nodeData: INodeData = null; public get uri() { - return this.nodeData.uri; + return this.nodeData && this.nodeData.uri; } public get moduleName() { - return this.nodeData.moduleName; + return this.nodeData && this.nodeData.moduleName; } public get path() { - return this.nodeData.path; + return this.nodeData && this.nodeData.path; } public get kind() { diff --git a/src/views/hierarchicalPackageNode.ts b/src/views/hierarchicalPackageNode.ts index e5737b0c..0a1f2028 100644 --- a/src/views/hierarchicalPackageNode.ts +++ b/src/views/hierarchicalPackageNode.ts @@ -21,9 +21,7 @@ export class HierarchicalPackageNode extends PackageNode { if (this._nodeData) { const item = new TreeItem(this.getHierarchicalNodeData().displayName, this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None); - item.iconPath = this.iconPath; - item.command = this.command; - return item; + return { ...super.getTreeItem(), ...item }; } } From ec773d34e05e03cc9469cc5f7f9c34fca61dbde2 Mon Sep 17 00:00:00 2001 From: Vigilans Date: Tue, 19 Nov 2019 12:02:26 +0800 Subject: [PATCH 3/3] Support showing file path as description for external jar files --- src/views/packageRootNode.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/views/packageRootNode.ts b/src/views/packageRootNode.ts index 0f7e9c2e..9ba8d80c 100644 --- a/src/views/packageRootNode.ts +++ b/src/views/packageRootNode.ts @@ -41,6 +41,15 @@ export class PackageRootNode extends DataNode { return result; } + protected get description(): string | boolean { + const data = this.nodeData; + if (data.entryKind === PackageRootKind.K_BINARY) { + return data.path; + } else { + return undefined; + } + } + protected get iconPath(): { light: string; dark: string } { const data = this.nodeData; if (data.entryKind === PackageRootKind.K_BINARY) {