Skip to content

Extract the nodes of empty-name packge root out #211

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/views/dataNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ export abstract class DataNode extends ExplorerNode {

protected abstract loadData(): Thenable<any[]>;

protected abstract createChildNodeList(): ExplorerNode[];
protected abstract createChildNodeList(): ProviderResult<ExplorerNode[]>;
}
4 changes: 4 additions & 0 deletions src/views/explorerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export abstract class ExplorerNode {
return this._parent;
}

public setParent(parent: ExplorerNode) {
this._parent = parent;
}

protected get command(): Command {
return undefined;
}
Expand Down
17 changes: 12 additions & 5 deletions src/views/projectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,24 @@ export class ProjectNode extends DataNode {
});
}

protected createChildNodeList(): ExplorerNode[] {

protected async createChildNodeList(): Promise<ExplorerNode[]> {
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) => {
Expand Down