From 699cc74beee6d2b2666ab88cac0fbd4075a7c6af Mon Sep 17 00:00:00 2001 From: Vigilans Date: Tue, 19 Nov 2019 13:33:56 +0800 Subject: [PATCH] Extract the nodes of empty-name packge root out --- src/views/dataNode.ts | 2 +- src/views/explorerNode.ts | 4 ++++ src/views/projectNode.ts | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/views/dataNode.ts b/src/views/dataNode.ts index d9624eab..b8ce45d8 100644 --- a/src/views/dataNode.ts +++ b/src/views/dataNode.ts @@ -67,5 +67,5 @@ export abstract class DataNode extends ExplorerNode { protected abstract loadData(): Thenable; - protected abstract createChildNodeList(): ExplorerNode[]; + protected abstract createChildNodeList(): ProviderResult; } diff --git a/src/views/explorerNode.ts b/src/views/explorerNode.ts index da849ab5..462d92a4 100644 --- a/src/views/explorerNode.ts +++ b/src/views/explorerNode.ts @@ -20,6 +20,10 @@ export abstract class ExplorerNode { return this._parent; } + public setParent(parent: ExplorerNode) { + this._parent = parent; + } + protected get command(): Command { return undefined; } diff --git a/src/views/projectNode.ts b/src/views/projectNode.ts index 01298b0e..b0409c90 100644 --- a/src/views/projectNode.ts +++ b/src/views/projectNode.ts @@ -45,17 +45,24 @@ export class ProjectNode extends DataNode { }); } - protected createChildNodeList(): ExplorerNode[] { - + protected async createChildNodeList(): Promise { const result = []; if (this.nodeData.children && this.nodeData.children.length) { - this.nodeData.children.forEach((data) => { + for (const data of this.nodeData.children) { if (data.kind === NodeKind.Container) { result.push(new ContainerNode(data, this, this)); } else if (data.kind === NodeKind.PackageRoot) { - result.push(NodeFactory.createPackageRootNode(data, this, this)); + const node = NodeFactory.createPackageRootNode(data, this, this); + if (!data.name) { // Extract the nodes of empty-name packge root out + for (const child of await node.getChildren()) { + child.setParent(this); + result.push(child); + } + } else { + result.push(node); + } } - }); + } } result.sort((a: DataNode, b: DataNode) => {