snippetsSync.ts ×16

Frontier kind: Code frontier

unlabeled · c_3f4a16b16578

139 tests · 25285 LOC · 133 files · introduces 0 tests · 61 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges61 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3986 ranges25285 lines · 133 files · Browse complete extent
All tests (intent)
139 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: 61 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/snippetsSync.ts 55 introduced LOC · 16 ranges

Open complete file

60
61 protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<ISnippetsResourcePreview[]> {
62 > const local = await this.getSnippetsFileContents(); snippetsSync.ts
63 > const localSnippets = this.toSnippetsContents(local);
64 > const remoteSnippets: IStringDictionary<string> | null = remoteUserData.syncData ? this.parseSnippets(remoteUserData.syncData) : null;
65 >
66 > // Use remote data as last sync data if last sync data does not exist and remote data is from same machine
67 > lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
68 > const lastSyncSnippets: IStringDictionary<string> | null = lastSyncUserData && lastSyncUserData.syncData ? this.parseSnippets(lastSyncUserData.syncData) : null;
69 >
70 > if (remoteSnippets) {
71 this.logService.trace(`${this.syncResourceLogLabel}: Merging remote snippets with local snippets...`);
72 > } else { snippetsSync.ts
73 > this.logService.trace(`${this.syncResourceLogLabel}: Remote snippets does not exist. Synchronizing snippets for the first time.`);
74 > }
75 >
76 > const mergeResult = merge(localSnippets, remoteSnippets, lastSyncSnippets);
77 > return this.getResourcePreviews(mergeResult, local, remoteSnippets || {}, lastSyncSnippets || {});
78 > }
79
80 protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {
174
175 private getResourcePreviews(snippetsMergeResult: ISnippetsMergeResult, localFileContent: IStringDictionary<IFileContent>, remoteSnippets: IStringDictionary<string>, baseSnippets: IStringDictionary<string>): ISnippetsResourcePreview[] {
176 > const resourcePreviews: Map<string, ISnippetsResourcePreview> = new Map<string, ISnippetsResourcePreview>(); snippetsSync.ts
177 >
178 > /* Snippets added remotely -> add locally */
179 > for (const key of Object.keys(snippetsMergeResult.local.added)) {
180 const previewResult: IMergeResult = {
181 content: snippetsMergeResult.local.added[key],
199 });
200 }
202 > /* Snippets updated remotely -> update locally */
203 > for (const key of Object.keys(snippetsMergeResult.local.updated)) {
204 const previewResult: IMergeResult = {
205 content: snippetsMergeResult.local.updated[key],
224 });
225 }
227 > /* Snippets removed remotely -> remove locally */
228 > for (const key of snippetsMergeResult.local.removed) {
229 const previewResult: IMergeResult = {
230 content: null,
249 });
250 }
252 > /* Snippets added locally -> add remotely */
253 > for (const key of Object.keys(snippetsMergeResult.remote.added)) {
254 const previewResult: IMergeResult = {
255 content: snippetsMergeResult.remote.added[key],
274 });
275 }
277 > /* Snippets updated locally -> update remotely */
278 > for (const key of Object.keys(snippetsMergeResult.remote.updated)) {
279 const previewResult: IMergeResult = {
280 content: snippetsMergeResult.remote.updated[key],
299 });
300 }
302 > /* Snippets removed locally -> remove remotely */
303 > for (const key of snippetsMergeResult.remote.removed) {
304 const previewResult: IMergeResult = {
305 content: null,
323 });
324 }
326 > /* Snippets with conflicts */
327 > for (const key of snippetsMergeResult.conflicts) {
328 const previewResult: IMergeResult = {
329 content: baseSnippets[key] ?? null,
348 });
349 }
351 > /* Unmodified Snippets */
352 > for (const key of Object.keys(localFileContent)) {
353 if (!resourcePreviews.has(key)) {
354 const previewResult: IMergeResult = {
375 }
376 }
378 > return [...resourcePreviews.values()];
379 > }
380
381 override async resolveContent(uri: URI): Promise<string | null> {
470
471 private toSnippetsContents(snippetsFileContents: IStringDictionary<IFileContent>): IStringDictionary<string> {
472 > const snippets: IStringDictionary<string> = {}; snippetsSync.ts
473 > for (const key of Object.keys(snippetsFileContents)) {
474 snippets[key] = snippetsFileContents[key].value.toString();
475 }
476 > return snippets; snippetsSync.ts
477 > }
478
479 private async getSnippetsFileContents(): Promise<IStringDictionary<IFileContent>> {
480 > const snippets: IStringDictionary<IFileContent> = {}; snippetsSync.ts
481 > let stat: IFileStat;
482 > try {
483 > stat = await this.fileService.resolve(this.snippetsFolder);
484 > } catch (e) {
485 // No snippets
486 if (e instanceof FileOperationError && e.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
490 }
491 }
492 > for (const entry of stat.children || []) { snippetsSync.ts
493 const resource = entry.resource;
494 const extension = this.extUri.extname(resource);
src/vs/platform/userDataSync/common/snippetsMerge.ts 6 introduced LOC · 1 range

Open complete file

26
27 if (!remote) {
28 > return { snippetsMerge.ts
29 > local: { added: localAdded, updated: localUpdated, removed: [...localRemoved.values()] },
30 > remote: { added: local, updated: {}, removed: [] },
31 > conflicts: []
32 > };
33 > }
34
35 const localToRemote = compare(local, remote);