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

Method getPackages

src/helpViewer/packages.ts:243–273  ·  view source on GitHub ↗
(fromCran: boolean = false)

Source from the content-addressed store, hash-verified

241 }
242
243 public async getPackages(fromCran: boolean = false): Promise<Package[]|undefined> {
244 let packages: Package[]|undefined;
245 this.pullFavoriteNames();
246 if(fromCran){
247 // Use a placeholder, since multiple different urls are attempted
248 const CRAN_PATH_PLACEHOLDER = 'CRAN_PATH_PLACEHOLDER';
249
250 packages = this.getCachedIndexFile(CRAN_PATH_PLACEHOLDER);
251 if(!packages?.length){
252 const cranUrl = await getCranUrl('', this.cwd);
253 packages = await getPackagesFromCran(cranUrl);
254 await this.updateCachedIndexFile(CRAN_PATH_PLACEHOLDER, packages);
255 }
256 } else{
257 packages = await this.getParsedIndexFile(`/doc/html/packages.html`);
258 if(!packages?.length){
259 void vscode.window.showErrorMessage('Help provider not available!');
260 }
261 }
262 if(packages){
263 for(const pkg of packages){
264 pkg.isFavorite = this.favoriteNames.has(pkg.name);
265 pkg.helpPath = (
266 pkg.name === 'doc' ?
267 '/doc/html/packages.html' :
268 `/library/${pkg.name}/html/00Index.html`
269 );
270 }
271 }
272 return packages;
273 }
274
275
276 // parses a package's index file to produce a list of help topics

Callers 2

makeChildrenMethod · 0.80

Calls 7

pullFavoriteNamesMethod · 0.95
getCachedIndexFileMethod · 0.95
updateCachedIndexFileMethod · 0.95
getParsedIndexFileMethod · 0.95
getCranUrlFunction · 0.90
getPackagesFromCranFunction · 0.90
hasMethod · 0.80

Tested by

no test coverage detected