settingsSync.ts ×10

Frontier kind: Code frontier

unlabeled · c_3aa194fe8d0a

145 tests · 25615 LOC · 133 files · introduces 0 tests · 90 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges90 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4067 ranges25615 lines · 133 files · Browse complete extent
All tests (intent)
145 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.

3 files ranked by introduced lines: 90 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/settingsSync.ts 73 introduced LOC · 10 ranges

Open complete file

84
85 protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<ISettingsResourcePreview[]> {
86 > const fileContent = await this.getLocalFileContent(); settingsSync.ts
87 > const formattingOptions = await this.getFormattingOptions();
88 > const remoteSettingsSyncContent = this.getSettingsSyncContent(remoteUserData);
89 >
90 > // Use remote data as last sync data if last sync data does not exist and remote data is from same machine
91 > lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
92 > const lastSettingsSyncContent: ISettingsSyncContent | null = lastSyncUserData ? this.getSettingsSyncContent(lastSyncUserData) : null;
93 > const ignoredSettings = await this.getIgnoredSettings();
94 >
95 > let mergedContent: string | null = null;
96 > let hasLocalChanged: boolean = false;
97 > let hasRemoteChanged: boolean = false;
98 > let hasConflicts: boolean = false;
99 >
100 > if (remoteSettingsSyncContent) {
101 let localContent: string = fileContent ? fileContent.value.toString().trim() : '{}';
102 localContent = localContent || '{}';
109 hasConflicts = result.hasConflicts;
110 }
112 > // First time syncing to remote
113 > else if (fileContent) {
114 this.logService.trace(`${this.syncResourceLogLabel}: Remote settings does not exist. Synchronizing settings for the first time.`);
115 mergedContent = fileContent.value.toString().trim() || '{}';
118 }
119
120 > const localContent = fileContent ? fileContent.value.toString() : null; settingsSync.ts
121 > const baseContent = lastSettingsSyncContent?.settings ?? null;
122 >
123 > const previewResult = {
124 > content: hasConflicts ? baseContent : mergedContent,
125 > localChange: hasLocalChanged ? Change.Modified : Change.None,
126 > remoteChange: hasRemoteChanged ? Change.Modified : Change.None,
127 > hasConflicts
128 > };
129 >
130 > return [{
131 > fileContent,
132 >
133 > baseResource: this.baseResource,
134 > baseContent,
135 >
136 > localResource: this.localResource,
137 > localContent,
138 > localChange: previewResult.localChange,
139 >
140 > remoteResource: this.remoteResource,
141 > remoteContent: remoteSettingsSyncContent ? remoteSettingsSyncContent.settings : null,
142 > remoteChange: previewResult.remoteChange,
143 >
144 > previewResource: this.previewResource,
145 > previewResult,
146 > acceptedResource: this.acceptedResource,
147 > }];
148 > }
149
150 protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {
302
303 private getSettingsSyncContent(remoteUserData: IRemoteUserData): ISettingsSyncContent | null {
304 > return remoteUserData.syncData ? this.parseSettingsSyncContent(remoteUserData.syncData.content) : null; settingsSync.ts
305 > }
306
307 private parseSettingsSyncContent(syncContent: string): ISettingsSyncContent | null {
322 private userExtensionsIgnoredSettings: Promise<string[]> | undefined = undefined;
323 private async getIgnoredSettings(content?: string): Promise<string[]> {
324 > if (!this.coreIgnoredSettings) { settingsSync.ts
325 > this.coreIgnoredSettings = this.userDataSyncUtilService.resolveDefaultCoreIgnoredSettings();
326 > }
327 > if (!this.systemExtensionsIgnoredSettings) {
328 > this.systemExtensionsIgnoredSettings = this.getIgnoredSettingForSystemExtensions();
329 > }
330 > if (!this.userExtensionsIgnoredSettings) {
331 > this.userExtensionsIgnoredSettings = this.getIgnoredSettingForUserExtensions();
332 > const disposable = this._register(Event.any<any>(
333 > Event.filter(this.extensionManagementService.onDidInstallExtensions, (e => e.some(({ local }) => !!local))),
334 > Event.filter(this.extensionManagementService.onDidUninstallExtension, (e => !e.error)))(() => {
335 disposable.dispose();
336 this.userExtensionsIgnoredSettings = undefined;
337 > })); settingsSync.ts
338 > }
339 > const defaultIgnoredSettings = (await Promise.all([this.coreIgnoredSettings, this.systemExtensionsIgnoredSettings, this.userExtensionsIgnoredSettings])).flat();
340 > return getIgnoredSettings(defaultIgnoredSettings, this.configurationService, content);
341 > }
342
343 private async getIgnoredSettingForSystemExtensions(): Promise<string[]> {
344 > const systemExtensions = await this.extensionManagementService.getInstalled(ExtensionType.System); settingsSync.ts
345 > return distinct(systemExtensions.map(e => getIgnoredSettingsForExtension(e.manifest)).flat());
346 > }
347
348 private async getIgnoredSettingForUserExtensions(): Promise<string[]> {
349 > const userExtensions = await this.extensionManagementService.getInstalled(ExtensionType.User, this.profile.extensionsResource); settingsSync.ts
350 > return distinct(userExtensions.map(e => getIgnoredSettingsForExtension(e.manifest)).flat());
351 > }
352
353 private validateContent(content: string): void {
354 > if (this.hasErrors(content, false)) { settingsSync.ts
355 throw new UserDataSyncError(localize('errorInvalidSettings', "Unable to sync settings as there are errors/warning in settings file."), UserDataSyncErrorCode.LocalInvalidContent, this.resource);
356 }
357 > } settingsSync.ts
358
359 }
src/vs/platform/userDataSync/common/settingsMerge.ts 15 introduced LOC · 5 ranges

Open complete file

22
23 export function getIgnoredSettings(defaultIgnoredSettings: string[], configurationService: IConfigurationService, settingsContent?: string): string[] {
24 > let value: ReadonlyArray<string> = []; settingsMerge.ts
25 > if (settingsContent) {
26 value = getIgnoredSettingsFromContent(settingsContent);
27 > } else { settingsMerge.ts
28 > value = getIgnoredSettingsFromConfig(configurationService);
29 > }
30 > const added: string[] = [], removed: string[] = [...getDisallowedIgnoredSettings()];
31 > if (Array.isArray(value)) {
32 > for (const key of value) {
33 if (key.startsWith('-')) {
34 removed.push(key.substring(1));
37 }
38 }
40 > return distinct([...defaultIgnoredSettings, ...added,].filter(setting => !removed.includes(setting)));
41 > }
42
43 > function getIgnoredSettingsFromConfig(configurationService: IConfigurationService): ReadonlyArray<string> { settingsMerge.ts
44 > let userValue = configurationService.inspect<string[]>('settingsSync.ignoredSettings').userValue;
45 > if (userValue !== undefined) {
46 return userValue;
47 }
51 }
52 return configurationService.getValue<string[]>('settingsSync.ignoredSettings') || [];
54
55 function getIgnoredSettingsFromContent(settingsContent: string): string[] {
src/vs/platform/userDataSync/test/common/userDataSyncClient.ts 2 introduced LOC · 1 range

Open complete file

375
376 async resolveDefaultCoreIgnoredSettings(): Promise<string[]> {
377 > return getDefaultIgnoredSettings(); userDataSyncClient.ts
378 > }
379
380 async resolveUserBindings(userbindings: string[]): Promise<IStringDictionary<string>> {