snippetsSync.ts ×11

Frontier kind: Code frontier

unlabeled · c_b18791efd1ff

71 tests · 25793 LOC · 133 files · introduces 0 tests · 55 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges55 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4147 ranges25793 lines · 133 files · Browse complete extent
All tests (intent)
71 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: 55 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

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

Open complete file

90
91 protected async getMergeResult(resourcePreview: ISnippetsResourcePreview, token: CancellationToken): Promise<IMergeResult> {
92 > return resourcePreview.previewResult; snippetsSync.ts
93 > }
94
95 protected async getAcceptResult(resourcePreview: ISnippetsResourcePreview, resource: URI, content: string | null | undefined, token: CancellationToken): Promise<IAcceptResult> {
97 > /* Accept local resource */
98 > if (this.extUri.isEqualOrParent(resource, this.syncPreviewFolder.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'local' }))) {
99 return {
100 content: resourcePreview.fileContent ? resourcePreview.fileContent.value.toString() : null,
105 };
106 }
108 > /* Accept remote resource */
109 > if (this.extUri.isEqualOrParent(resource, this.syncPreviewFolder.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'remote' }))) {
110 return {
111 content: resourcePreview.remoteContent,
116 };
117 }
119 > /* Accept preview resource */
120 > if (this.extUri.isEqualOrParent(resource, this.syncPreviewFolder)) {
121 > if (content === undefined) {
122 > return {
123 > content: resourcePreview.previewResult.content,
124 > localChange: resourcePreview.previewResult.localChange,
125 > remoteChange: resourcePreview.previewResult.remoteChange,
126 > };
127 > } else {
128 return {
129 content,
136 };
137 }
138 > } snippetsSync.ts
139
140 throw new Error(`Invalid Resource: ${resource.toString()}`);
141 > } snippetsSync.ts
142
143 protected async applyResult(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, resourcePreviews: [ISnippetsResourcePreview, IAcceptResult][], force: boolean): Promise<void> {
252 /* Snippets added locally -> add remotely */
253 for (const key of Object.keys(snippetsMergeResult.remote.added)) {
254 > const previewResult: IMergeResult = { snippetsSync.ts
255 > content: snippetsMergeResult.remote.added[key],
256 > hasConflicts: false,
257 > localChange: Change.None,
258 > remoteChange: Change.Added,
259 > };
260 > const localContent = localFileContent[key] ? localFileContent[key].value.toString() : null;
261 > resourcePreviews.set(key, {
262 > baseResource: this.extUri.joinPath(this.syncPreviewFolder, key).with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'base' }),
263 > baseContent: baseSnippets[key] ?? null,
264 > localResource: this.extUri.joinPath(this.syncPreviewFolder, key).with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'local' }),
265 > fileContent: localFileContent[key],
266 > localContent,
267 > remoteResource: this.extUri.joinPath(this.syncPreviewFolder, key).with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'remote' }),
268 > remoteContent: null,
269 > previewResource: this.extUri.joinPath(this.syncPreviewFolder, key),
270 > previewResult,
271 > localChange: previewResult.localChange,
272 > remoteChange: previewResult.remoteChange,
273 > acceptedResource: this.extUri.joinPath(this.syncPreviewFolder, key).with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'accepted' })
274 > });
275 > }
276
277 /* Snippets updated locally -> update remotely */
351 /* Unmodified Snippets */
352 for (const key of Object.keys(localFileContent)) {
353 > if (!resourcePreviews.has(key)) { snippetsSync.ts
354 const previewResult: IMergeResult = {
355 content: localFileContent[key] ? localFileContent[key].value.toString() : null,
374 });
375 }
376 > } snippetsSync.ts
377
378 return [...resourcePreviews.values()];
472 const snippets: IStringDictionary<string> = {};
473 for (const key of Object.keys(snippetsFileContents)) {
474 > snippets[key] = snippetsFileContents[key].value.toString(); snippetsSync.ts
475 > }
476 return snippets;
477 }
491 }
492 for (const entry of stat.children || []) {
493 > const resource = entry.resource; snippetsSync.ts
494 > const extension = this.extUri.extname(resource);
495 > if (extension === '.json' || extension === '.code-snippets') {
496 > const key = this.extUri.relativePath(this.snippetsFolder, resource)!;
497 > const content = await this.fileService.readFile(resource);
498 > snippets[key] = content;
499 > }
500 > }
501 > return snippets;
502 }
503 }