MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / getChildren

Method getChildren

src/workspaceViewer.ts:72–130  ·  view source on GitHub ↗
(element?: TreeItem)

Source from the content-addressed store, hash-verified

70 }
71
72 public async getChildren(element?: TreeItem): Promise<TreeItem[]> {
73 if (element) {
74 if (this.data === undefined) {
75 return [];
76 }
77 const pkgPrefix = 'package:';
78 if (element.id === 'attached-namespaces') {
79 await populatePackageNodes();
80 return this.data.search.map(name => {
81 if (name.startsWith(pkgPrefix)) {
82 const pkgName = name.substring(pkgPrefix.length);
83 const pkgNode = getPackageNode(pkgName);
84 return new PackageItem(name, pkgName, pkgNode);
85 } else {
86 const item = new TreeItem(name, TreeItemCollapsibleState.None);
87 item.iconPath = new ThemeIcon('symbol-array');
88 return item;
89 }
90 });
91 } else if (element.id === 'loaded-namespaces') {
92 await populatePackageNodes();
93 const attached_packages = this.data.search
94 .filter(name => name.startsWith(pkgPrefix))
95 .map(name => name.substring(pkgPrefix.length));
96 return this.data.loaded_namespaces.map(name => {
97 const pkgNode = getPackageNode(name);
98 const item = new PackageItem(name, name, pkgNode);
99 if (attached_packages.includes(name)) {
100 item.description = 'attached';
101 }
102 return item;
103 });
104 } else if (element.id === 'globalenv') {
105 return this.getGlobalEnvItems(this.data.globalenv);
106 } else if (element instanceof GlobalEnvItem) {
107 return element.str
108 .split('\n')
109 .filter((elem, index) => { return index > 0; })
110 .map(strItem =>
111 new GlobalEnvItem(
112 '',
113 '',
114 strItem.replace(/\s+/g, ' ').trim(),
115 '',
116 0,
117 element.treeLevel + 1
118 )
119 );
120 } else {
121 return [];
122 }
123 } else {
124 const treeItems = [this.attachedNamespacesRootItem, this.loadedNamespacesRootItem];
125 if (config().get<boolean>('session.watchGlobalEnvironment')) {
126 treeItems.push(this.globalEnvRootItem);
127 }
128 return treeItems;
129 }

Callers 1

populatePackageNodesFunction · 0.45

Calls 5

getGlobalEnvItemsMethod · 0.95
configFunction · 0.90
populatePackageNodesFunction · 0.85
getPackageNodeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected