Skip to content

Commit 9382344

Browse files
Vigilanstestforstephen
authored andcommitted
Support showing file path as description for external jar files (#209)
* Support description of treeitem * Fix: HierarchicalPacageNode should reuse DataNode's method to create treeitem * Support showing file path as description for external jar files
1 parent 5c4660a commit 9382344

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/java/hierarchicalPackageNodeData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export class HierarchicalPackageNodeData implements INodeData {
1818
private nodeData: INodeData = null;
1919

2020
public get uri() {
21-
return this.nodeData.uri;
21+
return this.nodeData && this.nodeData.uri;
2222
}
2323

2424
public get moduleName() {
25-
return this.nodeData.moduleName;
25+
return this.nodeData && this.nodeData.moduleName;
2626
}
2727

2828
public get path() {
29-
return this.nodeData.path;
29+
return this.nodeData && this.nodeData.path;
3030
}
3131

3232
public get kind() {

src/views/dataNode.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export abstract class DataNode extends ExplorerNode {
1414
public getTreeItem(): TreeItem | Promise<TreeItem> {
1515
if (this._nodeData) {
1616
const item = new TreeItem(this._nodeData.name, this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None);
17+
item.description = this.description;
1718
item.iconPath = this.iconPath;
1819
item.command = this.command;
1920
item.contextValue = this.computeContextValue();
@@ -80,6 +81,10 @@ export abstract class DataNode extends ExplorerNode {
8081
return true;
8182
}
8283

84+
protected get description(): string | boolean {
85+
return undefined;
86+
}
87+
8388
protected get contextValue(): string {
8489
return undefined;
8590
}

src/views/hierarchicalPackageNode.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export class HierarchicalPackageNode extends PackageNode {
2121
if (this._nodeData) {
2222
const item = new TreeItem(this.getHierarchicalNodeData().displayName,
2323
this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None);
24-
item.iconPath = this.iconPath;
25-
item.command = this.command;
26-
return item;
24+
return { ...super.getTreeItem(), ...item };
2725
}
2826
}
2927

src/views/packageRootNode.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ export class PackageRootNode extends DataNode {
4242
return result;
4343
}
4444

45+
protected get description(): string | boolean {
46+
const data = <IPackageRootNodeData>this.nodeData;
47+
if (data.entryKind === PackageRootKind.K_BINARY) {
48+
return data.path;
49+
} else {
50+
return undefined;
51+
}
52+
}
53+
4554
protected get contextValue(): string {
4655
const data = <IPackageRootNodeData>this.nodeData;
4756
if (data.entryKind === PackageRootKind.K_BINARY) {

0 commit comments

Comments
 (0)