extensionsProfileScannerService.ts ×14

Frontier kind: Code frontier

unlabeled · c_5ca912559e43

55 tests · 15335 LOC · 73 files · introduces 0 tests · 129 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges129 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1992 ranges15335 lines · 73 files · Browse complete extent
All tests (intent)
55 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.

1 file ranked by introduced lines: 129 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/extensionManagement/common/extensionsProfileScannerService.ts 129 introduced LOC · 14 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- extensionsProfileScannerService.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { Queue } from '../../../base/common/async.js';
7 > import { VSBuffer } from '../../../base/common/buffer.js';
8 > import { Disposable } from '../../../base/common/lifecycle.js';
9 > import { Emitter, Event } from '../../../base/common/event.js';
10 > import { ResourceMap } from '../../../base/common/map.js';
11 > import { URI, UriComponents } from '../../../base/common/uri.js';
12 > import { Metadata, isIExtensionIdentifier } from './extensionManagement.js';
13 > import { areSameExtensions } from './extensionManagementUtil.js';
14 > import { IExtension, IExtensionIdentifier } from '../../extensions/common/extensions.js';
15 > import { FileOperationResult, IFileService, toFileOperationResult } from '../../files/common/files.js';
16 > import { createDecorator } from '../../instantiation/common/instantiation.js';
17 > import { ILogService } from '../../log/common/log.js';
18 > import { IUserDataProfilesService } from '../../userDataProfile/common/userDataProfile.js';
19 > import { IUriIdentityService } from '../../uriIdentity/common/uriIdentity.js';
20 > import { Mutable, isObject, isString, isUndefined } from '../../../base/common/types.js';
21 > import { getErrorMessage } from '../../../base/common/errors.js';
22 >
23 > interface IStoredProfileExtension {
24 > identifier: IExtensionIdentifier;
25 > location: UriComponents | string;
26 > relativeLocation: string | undefined;
27 > version: string;
28 > metadata?: Metadata;
29 > }
30 >
31 > export const enum ExtensionsProfileScanningErrorCode {
32 >
33 > /**
34 > * Error when trying to scan extensions from a profile that does not exist.
35 > */
36 > ERROR_PROFILE_NOT_FOUND = 'ERROR_PROFILE_NOT_FOUND',
37 >
38 > /**
39 > * Error when profile file is invalid.
40 > */
41 > ERROR_INVALID_CONTENT = 'ERROR_INVALID_CONTENT',
42 >
43 > }
44 >
45 > export class ExtensionsProfileScanningError extends Error {
46 > constructor(message: string, public code: ExtensionsProfileScanningErrorCode) {
47 super(message);
48 }
50 >
51 > export interface IScannedProfileExtension {
52 > readonly identifier: IExtensionIdentifier;
53 > readonly version: string;
54 > readonly location: URI;
55 > readonly metadata?: Metadata;
56 > }
57 >
58 > export interface ProfileExtensionsEvent {
59 > readonly extensions: readonly IScannedProfileExtension[];
60 > readonly profileLocation: URI;
61 > }
62 >
63 > export interface DidAddProfileExtensionsEvent extends ProfileExtensionsEvent {
64 > readonly error?: Error;
65 > }
66 >
67 > export interface DidRemoveProfileExtensionsEvent extends ProfileExtensionsEvent {
68 > readonly error?: Error;
69 > }
70 >
71 > export interface IProfileExtensionsScanOptions {
72 > readonly bailOutWhenFileNotFound?: boolean;
73 > }
74 >
75 > export const IExtensionsProfileScannerService = createDecorator<IExtensionsProfileScannerService>('IExtensionsProfileScannerService');
76 > export interface IExtensionsProfileScannerService {
77 > readonly _serviceBrand: undefined;
78 >
79 > readonly onAddExtensions: Event<ProfileExtensionsEvent>;
80 > readonly onDidAddExtensions: Event<DidAddProfileExtensionsEvent>;
81 > readonly onRemoveExtensions: Event<ProfileExtensionsEvent>;
82 > readonly onDidRemoveExtensions: Event<DidRemoveProfileExtensionsEvent>;
83 >
84 > scanProfileExtensions(profileLocation: URI, options?: IProfileExtensionsScanOptions): Promise<IScannedProfileExtension[]>;
85 > addExtensionsToProfile(extensions: [IExtension, Metadata | undefined][], profileLocation: URI, keepExistingVersions?: boolean): Promise<IScannedProfileExtension[]>;
86 > updateMetadata(extensions: [IExtension, Metadata | undefined][], profileLocation: URI): Promise<IScannedProfileExtension[]>;
87 > removeExtensionsFromProfile(extensions: IExtensionIdentifier[], profileLocation: URI): Promise<void>;
88 > }
89 >
90 > export abstract class AbstractExtensionsProfileScannerService extends Disposable implements IExtensionsProfileScannerService {
91 > readonly _serviceBrand: undefined;
92 >
93 > private readonly _onAddExtensions = this._register(new Emitter<ProfileExtensionsEvent>());
94 > readonly onAddExtensions = this._onAddExtensions.event;
95 >
96 > private readonly _onDidAddExtensions = this._register(new Emitter<DidAddProfileExtensionsEvent>());
97 > readonly onDidAddExtensions = this._onDidAddExtensions.event;
98 >
99 > private readonly _onRemoveExtensions = this._register(new Emitter<ProfileExtensionsEvent>());
100 > readonly onRemoveExtensions = this._onRemoveExtensions.event;
101 >
102 > private readonly _onDidRemoveExtensions = this._register(new Emitter<DidRemoveProfileExtensionsEvent>());
103 > readonly onDidRemoveExtensions = this._onDidRemoveExtensions.event;
104 >
105 > private readonly resourcesAccessQueueMap = new ResourceMap<Queue<IScannedProfileExtension[]>>();
106 >
107 > constructor(
108 private readonly extensionsLocation: URI,
109 @IFileService private readonly fileService: IFileService,
114 super();
115 }
117 > scanProfileExtensions(profileLocation: URI, options?: IProfileExtensionsScanOptions): Promise<IScannedProfileExtension[]> {
118 return this.withProfileExtensions(profileLocation, undefined, options);
119 }
121 > async addExtensionsToProfile(extensions: [IExtension, Metadata | undefined][], profileLocation: URI, keepExistingVersions?: boolean): Promise<IScannedProfileExtension[]> {
122 const extensionsToRemove: IScannedProfileExtension[] = [];
123 const extensionsToAdd: IScannedProfileExtension[] = [];
172 }
173 }
175 > async updateMetadata(extensions: [IExtension, Metadata][], profileLocation: URI): Promise<IScannedProfileExtension[]> {
176 const updatedExtensions: IScannedProfileExtension[] = [];
177 await this.withProfileExtensions(profileLocation, profileExtensions => {
191 return updatedExtensions;
192 }
194 > async removeExtensionsFromProfile(extensions: IExtensionIdentifier[], profileLocation: URI): Promise<void> {
195 const extensionsToRemove: IScannedProfileExtension[] = [];
196 try {
219 }
220 }
222 > private async withProfileExtensions(file: URI, updateFn?: (extensions: Mutable<IScannedProfileExtension>[]) => IScannedProfileExtension[], options?: IProfileExtensionsScanOptions): Promise<IScannedProfileExtension[]> {
223 return this.getResourceAccessQueue(file).queue(async () => {
224 let extensions: IScannedProfileExtension[] = [];
301 });
302 }
304 > private throwInvalidConentError(file: URI): void {
305 throw new ExtensionsProfileScanningError(`Invalid extensions content in ${file.toString()}`, ExtensionsProfileScanningErrorCode.ERROR_INVALID_CONTENT);
306 }
308 > private toRelativePath(extensionLocation: URI): string | undefined {
309 return this.uriIdentityService.extUri.isEqual(this.uriIdentityService.extUri.dirname(extensionLocation), this.extensionsLocation)
310 ? this.uriIdentityService.extUri.basename(extensionLocation)
311 : undefined;
312 }
314 > private resolveExtensionLocation(path: string): URI {
315 return this.uriIdentityService.extUri.joinPath(this.extensionsLocation, path);
316 }
318 > private _migrationPromise: Promise<IStoredProfileExtension[] | undefined> | undefined;
319 > private async migrateFromOldDefaultProfileExtensionsLocation(): Promise<IStoredProfileExtension[] | undefined> {
320 if (!this._migrationPromise) {
321 this._migrationPromise = (async () => {
380 return this._migrationPromise;
381 }
383 > private getResourceAccessQueue(file: URI): Queue<IScannedProfileExtension[]> {
384 let resourceQueue = this.resourcesAccessQueueMap.get(file);
385 if (!resourceQueue) {
389 return resourceQueue;
390 }
392 >
393 function isStoredProfileExtension(obj: unknown): obj is IStoredProfileExtension {
394 const candidate = obj as IStoredProfileExtension | undefined;