in src/workspace-tree/bazel_workspace_tree_provider.ts [71:99]
public getChildren(element?: IBazelTreeItem): Thenable<IBazelTreeItem[]> {
// If we're given an element, we're not asking for the top-level elements,
// so just delegate to that element to get its children.
if (element) {
return element.getChildren();
}
if (this.workspaceFolderTreeItems === undefined) {
this.updateWorkspaceFolderTreeItems();
}
if (this.workspaceFolderTreeItems && vscode.workspace.workspaceFolders) {
// If the user has a workspace open and there's only one folder in it,
// then don't show the workspace folder; just show its packages at the top
// level.
if (vscode.workspace.workspaceFolders.length === 1) {
const folderItem = this.workspaceFolderTreeItems[0];
return folderItem.getChildren();
}
// If the user has multiple workspace folders open, then show them as
// individual top level items.
return Promise.resolve(this.workspaceFolderTreeItems);
}
// If the user doesn't have a folder open in the workspace, or none of them
// have Bazel workspaces, don't show anything.
return Promise.resolve([]);
}