extensionsScannerService.ts ×12

Frontier kind: Code frontier

unlabeled · c_d6c747750adb

8 tests · 19000 LOC · 82 files · introduces 0 tests · 65 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges65 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2997 ranges19000 lines · 82 files · Browse complete extent
All tests (intent)
8 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 65 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/extensionManagement/common/extensionsScannerService.ts 44 introduced LOC · 12 ranges

Open complete file

229
230 async scanUserExtensions(scanOptions: UserExtensionsScanOptions): Promise<IScannedExtension[]> {
231 > this.logService.trace('Started scanning user extensions', scanOptions.profileLocation); extensionsScannerService.ts
232 > const profileScanOptions: IProfileExtensionsScanOptions | undefined = this.uriIdentityService.extUri.isEqual(scanOptions.profileLocation, this.userDataProfilesService.defaultProfile.extensionsResource) ? { bailOutWhenFileNotFound: true } : undefined;
233 > const extensionsScannerInput = await this.createExtensionScannerInput(scanOptions.profileLocation, true, ExtensionType.User, scanOptions.language, true, profileScanOptions, scanOptions.productVersion ?? this.getProductVersion());
234 > const extensionsScanner = scanOptions.useCache && !extensionsScannerInput.devMode ? this.userExtensionsCachedScanner : this.extensionsScanner;
235 > let extensions: IRelaxedScannedExtension[];
236 > try {
237 > extensions = await extensionsScanner.scanExtensions(extensionsScannerInput);
238 > } catch (error) {
239 > if (error instanceof ExtensionsProfileScanningError && error.code === ExtensionsProfileScanningErrorCode.ERROR_PROFILE_NOT_FOUND) {
240 > await this.doInitializeDefaultProfileExtensions();
241 > extensions = await extensionsScanner.scanExtensions(extensionsScannerInput);
242 > } else {
243 throw error;
244 }
246 > extensions = await this.applyScanOptions(extensions, ExtensionType.User, { includeInvalid: scanOptions.includeInvalid, pickLatest: true });
247 > this.logService.trace('Scanned user extensions:', extensions.length);
248 > return extensions;
249 > }
250
251 async scanAllUserExtensions(scanOptions: { includeAllVersions?: boolean; includeInvalid: boolean } = { includeInvalid: true, includeAllVersions: true }): Promise<IScannedExtension[]> {
324 private initializeDefaultProfileExtensionsPromise: Promise<void> | undefined = undefined;
325 private async doInitializeDefaultProfileExtensions(): Promise<void> {
326 > if (!this.initializeDefaultProfileExtensionsPromise) { extensionsScannerService.ts
327 > this.initializeDefaultProfileExtensionsPromise = (async () => {
328 > try {
329 > this.logService.info('Started initializing default profile extensions in extensions installation folder.', this.userExtensionsLocation.toString());
330 > const userExtensions = await this.scanAllUserExtensions({ includeInvalid: true });
331 > if (userExtensions.length) {
332 await this.extensionsProfileScannerService.addExtensionsToProfile(userExtensions.map(e => [e, e.metadata]), this.userDataProfilesService.defaultProfile.extensionsResource);
334 try {
335 await this.fileService.createFile(this.userDataProfilesService.defaultProfile.extensionsResource, VSBuffer.fromString(JSON.stringify([])));
340 }
341 }
342 > this.logService.info('Completed initializing default profile extensions in extensions installation folder.', this.userExtensionsLocation.toString()); extensionsScannerService.ts
343 > } catch (error) {
344 this.logService.error(error);
345 > } finally { extensionsScannerService.ts
346 > this.initializeDefaultProfileExtensionsPromise = undefined;
347 > }
348 > })();
349 > }
350 > return this.initializeDefaultProfileExtensionsPromise;
351 > }
352
353 private async applyScanOptions(extensions: IRelaxedScannedExtension[], type: ExtensionType | 'development', scanOptions: { includeAllVersions?: boolean; includeInvalid?: boolean; pickLatest?: boolean } = {}): Promise<IRelaxedScannedExtension[]> {
606 async scanExtensions(input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
607 return input.profile
608 > ? this.scanExtensionsFromProfile(input) extensionsScannerService.ts
609 : this.scanExtensionsFromLocation(input);
610 }
633
634 private async scanExtensionsFromProfile(input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
635 > let profileExtensions = await this.scanExtensionsFromProfileResource(input.location, () => true, input); extensionsScannerService.ts
636 > if (input.applicationExtensionslocation && !this.uriIdentityService.extUri.isEqual(input.location, input.applicationExtensionslocation)) {
637 profileExtensions = profileExtensions.filter(e => !e.metadata?.isApplicationScoped);
638 const applicationExtensions = await this.scanExtensionsFromProfileResource(input.applicationExtensionslocation, (e) => !!e.metadata?.isBuiltin || !!e.metadata?.isApplicationScoped, input);
639 profileExtensions.push(...applicationExtensions);
640 }
641 > return profileExtensions; extensionsScannerService.ts
642 > }
643
644 private async scanExtensionsFromProfileResource(profileResource: URI, filter: (extensionInfo: IScannedProfileExtension) => boolean, input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
645 > const scannedProfileExtensions = await this.extensionsProfileScannerService.scanProfileExtensions(profileResource, input.profileScanOptions); extensionsScannerService.ts
646 > if (!scannedProfileExtensions.length) {
647 return [];
648 }
656 }));
657 return coalesce(extensions);
659
660 async scanOneOrMultipleExtensions(input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
src/vs/platform/extensionManagement/common/extensionsProfileScannerService.ts 21 introduced LOC · 6 ranges

Open complete file

235 // migrate from old location, remove this after couple of releases
236 if (this.uriIdentityService.extUri.isEqual(file, this.userDataProfilesService.defaultProfile.extensionsResource)) {
237 > storedProfileExtensions = await this.migrateFromOldDefaultProfileExtensionsLocation(); extensionsProfileScannerService.ts
238 > }
239 if (!storedProfileExtensions && options?.bailOutWhenFileNotFound) {
240 > throw new ExtensionsProfileScanningError(getErrorMessage(error), ExtensionsProfileScanningErrorCode.ERROR_PROFILE_NOT_FOUND); extensionsProfileScannerService.ts
241 > }
242 }
243 if (storedProfileExtensions) {
318 private _migrationPromise: Promise<IStoredProfileExtension[] | undefined> | undefined;
319 private async migrateFromOldDefaultProfileExtensionsLocation(): Promise<IStoredProfileExtension[] | undefined> {
320 > if (!this._migrationPromise) { extensionsProfileScannerService.ts
321 > this._migrationPromise = (async () => {
322 > const oldDefaultProfileExtensionsLocation = this.uriIdentityService.extUri.joinPath(this.userDataProfilesService.defaultProfile.location, 'extensions.json');
323 > const oldDefaultProfileExtensionsInitLocation = this.uriIdentityService.extUri.joinPath(this.extensionsLocation, '.init-default-profile-extensions');
324 > let content: string;
325 > try {
326 > content = (await this.fileService.readFile(oldDefaultProfileExtensionsLocation)).value.toString();
327 > } catch (error) {
328 > if (toFileOperationResult(error) === FileOperationResult.FILE_NOT_FOUND) {
329 > return undefined;
330 > }
331 throw error;
332 }
336 try {
337 const parsedData = JSON.parse(content);
338 > if (Array.isArray(parsedData) && parsedData.every(candidate => isStoredProfileExtension(candidate))) { extensionsProfileScannerService.ts
339 storedProfileExtensions = parsedData;
340 } else {
341 this.logService.warn('Skipping migrating from old default profile locaiton: Found invalid data', parsedData);
342 }
343 > } catch (error) { extensionsProfileScannerService.ts
344 /* Ignore */
345 this.logService.error(error);
376
377 return storedProfileExtensions;
379 > }
380 > return this._migrationPromise;
381 > }
382
383 private getResourceAccessQueue(file: URI): Queue<IScannedProfileExtension[]> {