promptsSync.ts ×16

Frontier kind: Code frontier

unlabeled · c_52fbc945f466

135 tests · 25290 LOC · 133 files · introduces 0 tests · 72 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges72 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3985 ranges25290 lines · 133 files · Browse complete extent
All tests (intent)
135 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: 72 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/promptsSync/promptsSync.ts 60 introduced LOC · 16 ranges

Open complete file

80
81 protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<IPromptsResourcePreview[]> {
82 > const local = await this.getPromptsFileContents(); promptsSync.ts
83 > const localPrompts = this.toPromptContents(local);
84 > const remotePrompts: IStringDictionary<string> | null = remoteUserData.syncData ? this.parsePrompts(remoteUserData.syncData) : null;
85 >
86 > // Use remote data as last sync data if last sync data does not exist and remote data is from same machine
87 > lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
88 > const lastSyncPrompts: IStringDictionary<string> | null = lastSyncUserData && lastSyncUserData.syncData ? this.parsePrompts(lastSyncUserData.syncData) : null;
89 >
90 > if (remotePrompts) {
91 this.logService.trace(`${this.syncResourceLogLabel}: Merging remote prompts with local prompts...`);
92 > } else { promptsSync.ts
93 > this.logService.trace(`${this.syncResourceLogLabel}: Remote prompts does not exist. Synchronizing prompts for the first time.`);
94 > }
95 >
96 > const mergeResult = merge(localPrompts, remotePrompts, lastSyncPrompts);
97 > return this.getResourcePreviews(mergeResult, local, remotePrompts || {}, lastSyncPrompts || {});
98 > }
99
100 protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {
194
195 private getResourcePreviews(
196 > mergeResult: IPromptsMergeResult, promptsSync.ts
197 > localFileContent: IStringDictionary<IFileContent>,
198 > remote: IStringDictionary<string>,
199 > base: IStringDictionary<string>,
200 > ): IPromptsResourcePreview[] {
201 > const resourcePreviews: Map<string, IPromptsResourcePreview> = new Map<string, IPromptsResourcePreview>();
202 >
203 > /* Prompts added remotely -> add locally */
204 > for (const key of Object.keys(mergeResult.local.added)) {
205 const previewResult: IMergeResult = {
206 content: mergeResult.local.added[key],
224 });
225 }
227 > /* Prompts updated remotely -> update locally */
228 > for (const key of Object.keys(mergeResult.local.updated)) {
229 const previewResult: IMergeResult = {
230 content: mergeResult.local.updated[key],
249 });
250 }
252 > /* Prompts removed remotely -> remove locally */
253 > for (const key of mergeResult.local.removed) {
254 const previewResult: IMergeResult = {
255 content: null,
274 });
275 }
277 > /* Prompts added locally -> add remotely */
278 > for (const key of Object.keys(mergeResult.remote.added)) {
279 const previewResult: IMergeResult = {
280 content: mergeResult.remote.added[key],
299 });
300 }
302 > /* Prompts updated locally -> update remotely */
303 > for (const key of Object.keys(mergeResult.remote.updated)) {
304 const previewResult: IMergeResult = {
305 content: mergeResult.remote.updated[key],
324 });
325 }
327 > /* Prompts removed locally -> remove remotely */
328 > for (const key of mergeResult.remote.removed) {
329 const previewResult: IMergeResult = {
330 content: null,
348 });
349 }
351 > /* Prompts with conflicts */
352 > for (const key of mergeResult.conflicts) {
353 const previewResult: IMergeResult = {
354 content: base[key] ?? null,
373 });
374 }
376 > /* Unmodified Prompts */
377 > for (const key of Object.keys(localFileContent)) {
378 if (!resourcePreviews.has(key)) {
379 const previewResult: IMergeResult = {
400 }
401 }
403 > return [...resourcePreviews.values()];
404 > }
405
406 override async resolveContent(uri: URI): Promise<string | null> {
495
496 private toPromptContents(fileContents: IStringDictionary<IFileContent>): IStringDictionary<string> {
497 > const prompts: IStringDictionary<string> = {}; promptsSync.ts
498 > for (const key of Object.keys(fileContents)) {
499 prompts[key] = fileContents[key].value.toString();
500 }
501 > return prompts; promptsSync.ts
502 > }
503
504 private async getPromptsFileContents(): Promise<IStringDictionary<IFileContent>> {
505 > const prompts: IStringDictionary<IFileContent> = {}; promptsSync.ts
506 > let stat: IFileStat;
507 > try {
508 > stat = await this.fileService.resolve(this.promptsFolder);
509 > } catch (e) {
510 // No prompts
511 if (e instanceof FileOperationError && e.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
515 }
516 }
517 > for (const entry of stat.children || []) { promptsSync.ts
518 const resource = entry.resource;
519 const path = resource.path;
src/vs/platform/userDataSync/common/promptsSync/promptsMerge.ts 12 introduced LOC · 2 ranges

Open complete file

21
22 export function merge(local: IStringDictionary<string>, remote: IStringDictionary<string> | null, base: IStringDictionary<string> | null): IMergeResult {
23 > const localAdded: IStringDictionary<string> = {}; promptsMerge.ts
24 > const localUpdated: IStringDictionary<string> = {};
25 > const localRemoved: Set<string> = new Set<string>();
26 >
27 > if (!remote) {
28 > return {
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);
36 > if (localToRemote.added.size === 0 && localToRemote.removed.size === 0 && localToRemote.updated.size === 0) { promptsMerge.ts
37 // No changes found between local and remote.
38 return {