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

Method getGlobalEnvItems

src/workspaceViewer.ts:132–173  ·  view source on GitHub ↗
(globalenv: GlobalEnv)

Source from the content-addressed store, hash-verified

130 }
131
132 private getGlobalEnvItems(globalenv: GlobalEnv): GlobalEnvItem[] {
133 const toItem = (
134 key: string,
135 rClass: string,
136 str: string,
137 type: string,
138 size?: number,
139 dim?: number[]
140 ): GlobalEnvItem => {
141 return new GlobalEnvItem(
142 key,
143 rClass,
144 str,
145 type,
146 size,
147 TreeLevel.Parent,
148 dim,
149 );
150 };
151
152 const items = globalenv ? Object.keys(globalenv).map((key) =>
153 toItem(
154 key,
155 globalenv[key].class[0],
156 globalenv[key].str,
157 globalenv[key].type,
158 globalenv[key].size,
159 globalenv[key].dim,
160 )) : [];
161
162 function sortItems(a: GlobalEnvItem, b: GlobalEnvItem) {
163 if (a.priority > b.priority) {
164 return -1;
165 } else if (a.priority < b.priority) {
166 return 1;
167 } else {
168 return (a.label && b.label) ? a.label.localeCompare(b.label) : 0;
169 }
170 }
171
172 return items.sort((a, b) => sortItems(a, b));
173 }
174}
175
176class PackageItem extends TreeItem {

Callers 1

getChildrenMethod · 0.95

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected