@noldova/code.editor.merge 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -2
- package/api/index.d.ts +491 -0
- package/api/index.js +13 -0
- package/api/index.js.map +1 -0
- package/enums/conflict-choice.js +15 -0
- package/enums/conflict-choice.js.map +1 -0
- package/enums/conflict-state.js +18 -0
- package/enums/conflict-state.js.map +1 -0
- package/enums/marker-section.js +15 -0
- package/enums/marker-section.js.map +1 -0
- package/exceptions/conflict-markers.exception.js +18 -0
- package/exceptions/conflict-markers.exception.js.map +1 -0
- package/models/merge-conflict.js +75 -0
- package/models/merge-conflict.js.map +1 -0
- package/models/merge-start.js +16 -0
- package/models/merge-start.js.map +1 -0
- package/package.json +30 -4
- package/resources.js +31 -0
- package/resources.js.map +1 -0
- package/services/conflict-markers.js +94 -0
- package/services/conflict-markers.js.map +1 -0
- package/services/merge-document.js +139 -0
- package/services/merge-document.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @noldova/code.editor.merge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The code editor's framework-free 3-way merge model: `MergeDocument`, which builds a result from a base and two sides over `@noldova/diff`, or reads one from a file with conflict markers, and keeps each conflict's choice, state and undo; `MergeConflict`, `ConflictChoice`, `ConflictState` and `ConflictMarkersException`.
|
|
4
|
+
It edits through `@noldova/code.editor`'s text model, has no DOM, and runs in a page, a worker or Node.
|
|
5
|
+
`@noldova/code.editor.merge.angular` shows it.
|
|
6
|
+
[documents/ARCHITECTURE.md](../../documents/ARCHITECTURE.md) says how its parts fit together.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import "@noldova/context.core";
|
|
10
|
+
import { Exception } from "@noldova/context.exceptions";
|
|
11
|
+
import type { TextChange, TextDocument, UndoHistory } from "@noldova/code.editor";
|
|
12
|
+
import type { IReadOnlyList } from "@noldova/context.collections";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Names the ways one merge conflict can be resolved from its two sides.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* {@link MergeConflict.choiceText} turns a choice into the text it stands
|
|
19
|
+
* for, and {@link MergeDocument.accept} writes that text into the conflict.
|
|
20
|
+
* When both sides are kept, they are joined with a line feed unless either
|
|
21
|
+
* side is empty or the first already ends with a line break.
|
|
22
|
+
*/
|
|
23
|
+
export declare enum ConflictChoice {
|
|
24
|
+
/**
|
|
25
|
+
* Keeps only our side of the conflict.
|
|
26
|
+
*/
|
|
27
|
+
Ours = "Ours",
|
|
28
|
+
/**
|
|
29
|
+
* Keeps only their side of the conflict.
|
|
30
|
+
*/
|
|
31
|
+
Theirs = "Theirs",
|
|
32
|
+
/**
|
|
33
|
+
* Keeps both sides, ours before theirs.
|
|
34
|
+
*/
|
|
35
|
+
BothOursFirst = "BothOursFirst",
|
|
36
|
+
/**
|
|
37
|
+
* Keeps both sides, theirs before ours.
|
|
38
|
+
*/
|
|
39
|
+
BothTheirsFirst = "BothTheirsFirst"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Describes what a merge conflict's current text matches.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* {@link MergeConflict.stateFor} compares the text in this order: the
|
|
47
|
+
* suggestion, ours, theirs, both ours first, both theirs first, and then the
|
|
48
|
+
* base; text that matches none of them is {@link ConflictState.Edited}.
|
|
49
|
+
*/
|
|
50
|
+
export declare enum ConflictState {
|
|
51
|
+
/**
|
|
52
|
+
* The text still equals the conflict's base text.
|
|
53
|
+
*/
|
|
54
|
+
Unresolved = "Unresolved",
|
|
55
|
+
/**
|
|
56
|
+
* The text equals our side.
|
|
57
|
+
*/
|
|
58
|
+
Ours = "Ours",
|
|
59
|
+
/**
|
|
60
|
+
* The text equals their side.
|
|
61
|
+
*/
|
|
62
|
+
Theirs = "Theirs",
|
|
63
|
+
/**
|
|
64
|
+
* The text equals both sides joined, ours first.
|
|
65
|
+
*/
|
|
66
|
+
BothOursFirst = "BothOursFirst",
|
|
67
|
+
/**
|
|
68
|
+
* The text equals both sides joined, theirs first.
|
|
69
|
+
*/
|
|
70
|
+
BothTheirsFirst = "BothTheirsFirst",
|
|
71
|
+
/**
|
|
72
|
+
* The text equals the suggestion set on the conflict.
|
|
73
|
+
*/
|
|
74
|
+
Suggested = "Suggested",
|
|
75
|
+
/**
|
|
76
|
+
* The text matches neither side, their combinations, the suggestion nor
|
|
77
|
+
* the base: it was edited by hand.
|
|
78
|
+
*/
|
|
79
|
+
Edited = "Edited"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Reports merged text whose conflict markers don't form valid conflicts, such
|
|
84
|
+
* as a marker out of place or a conflict that is never closed.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* {@link MergeDocument.fromMarkers} throws it, and
|
|
88
|
+
* {@link MergeDocument.readMarkers} returns it instead of throwing.
|
|
89
|
+
*/
|
|
90
|
+
export declare class ConflictMarkersException extends Exception {
|
|
91
|
+
/**
|
|
92
|
+
* `ConflictMarkersException`.
|
|
93
|
+
*/
|
|
94
|
+
readonly name: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The one-based line number where the markers stop parsing.
|
|
98
|
+
*/
|
|
99
|
+
readonly line: number;
|
|
100
|
+
/**
|
|
101
|
+
* Creates the exception with the message
|
|
102
|
+
* "The conflict markers don't parse at line `line`: `reason`."
|
|
103
|
+
*
|
|
104
|
+
* @param line The one-based line number of the faulty marker, or of the
|
|
105
|
+
* conflict that is never closed.
|
|
106
|
+
* @param reason A short reason without a final period; the message adds it.
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { ConflictMarkersException, MergeDocument } from "@noldova/code.editor.merge";
|
|
110
|
+
*
|
|
111
|
+
* const result = MergeDocument.readMarkers("a\n<<<<<<< HEAD\nX\n");
|
|
112
|
+
* if (result instanceof ConflictMarkersException)
|
|
113
|
+
* console.log(result.line); // 2
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
constructor(line: number, reason: string);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* One conflict of a three-way merge: the base text and both sides' texts,
|
|
121
|
+
* where it sits in the merged document, and an optional suggested
|
|
122
|
+
* resolution.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* {@link MergeDocument} keeps the conflict's position current with
|
|
126
|
+
* {@link MergeConflict.moveTo} as the document changes.
|
|
127
|
+
*/
|
|
128
|
+
export declare class MergeConflict {
|
|
129
|
+
/**
|
|
130
|
+
* The conflict's zero-based position in its document's list of conflicts.
|
|
131
|
+
*/
|
|
132
|
+
readonly index: number;
|
|
133
|
+
/**
|
|
134
|
+
* The common ancestor's text of the conflict.
|
|
135
|
+
*/
|
|
136
|
+
readonly base: string;
|
|
137
|
+
/**
|
|
138
|
+
* Our side's text of the conflict.
|
|
139
|
+
*/
|
|
140
|
+
readonly ours: string;
|
|
141
|
+
/**
|
|
142
|
+
* Their side's text of the conflict.
|
|
143
|
+
*/
|
|
144
|
+
readonly theirs: string;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a conflict with no suggestion.
|
|
147
|
+
*
|
|
148
|
+
* @param index The conflict's zero-based position in its list.
|
|
149
|
+
* @param base The common ancestor's text.
|
|
150
|
+
* @param ours Our side's text.
|
|
151
|
+
* @param theirs Their side's text.
|
|
152
|
+
* @param start The zero-based character offset where the conflict starts in
|
|
153
|
+
* the merged document.
|
|
154
|
+
* @param end The exclusive character offset where it ends.
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { MergeConflict } from "@noldova/code.editor.merge";
|
|
158
|
+
*
|
|
159
|
+
* const conflict = new MergeConflict(0, "b\n", "X\n", "Y\n", 0, 2);
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
constructor(index: number, base: string, ours: string, theirs: string, start: number, end: number);
|
|
163
|
+
/**
|
|
164
|
+
* The zero-based character offset where the conflict starts in the merged
|
|
165
|
+
* document; changes with {@link MergeConflict.moveTo}.
|
|
166
|
+
*/
|
|
167
|
+
get start(): number;
|
|
168
|
+
/**
|
|
169
|
+
* The exclusive character offset where the conflict ends in the merged
|
|
170
|
+
* document; changes with {@link MergeConflict.moveTo}.
|
|
171
|
+
*/
|
|
172
|
+
get end(): number;
|
|
173
|
+
/**
|
|
174
|
+
* The suggested resolution, or `null` until {@link MergeConflict.suggest}
|
|
175
|
+
* sets one.
|
|
176
|
+
*/
|
|
177
|
+
get suggestion(): string | null;
|
|
178
|
+
/**
|
|
179
|
+
* Moves the conflict to a new place in the merged document.
|
|
180
|
+
*
|
|
181
|
+
* @param start The new zero-based start offset.
|
|
182
|
+
* @param end The new exclusive end offset.
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* import { MergeConflict } from "@noldova/code.editor.merge";
|
|
186
|
+
*
|
|
187
|
+
* const conflict = new MergeConflict(0, "b\n", "X\n", "Y\n", 0, 2);
|
|
188
|
+
* conflict.moveTo(4, 6);
|
|
189
|
+
* conflict.start; // 4
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
moveTo(start: number, end: number): void;
|
|
193
|
+
/**
|
|
194
|
+
* Sets the suggested resolution, replacing any earlier one.
|
|
195
|
+
*
|
|
196
|
+
* @param text The suggested text for the conflict.
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { MergeConflict } from "@noldova/code.editor.merge";
|
|
200
|
+
*
|
|
201
|
+
* const conflict = new MergeConflict(0, "b\n", "X\n", "Y\n", 0, 2);
|
|
202
|
+
* conflict.suggest("XY\n");
|
|
203
|
+
* conflict.suggestion; // "XY\n"
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
suggest(text: string): void;
|
|
207
|
+
/**
|
|
208
|
+
* Gives the text a choice resolves the conflict to.
|
|
209
|
+
*
|
|
210
|
+
* @param choice The resolution to take.
|
|
211
|
+
* @returns Our text, their text, or both joined in the chosen order. When
|
|
212
|
+
* both are joined and neither is empty, a line feed is put between them
|
|
213
|
+
* unless the first already ends with a line ending.
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* import { ConflictChoice, MergeConflict } from "@noldova/code.editor.merge";
|
|
217
|
+
*
|
|
218
|
+
* const conflict = new MergeConflict(0, "b", "X", "Y", 0, 1);
|
|
219
|
+
* conflict.choiceText(ConflictChoice.BothTheirsFirst); // "Y\nX"
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
choiceText(choice: ConflictChoice): string;
|
|
223
|
+
/**
|
|
224
|
+
* Classifies the conflict's current text.
|
|
225
|
+
*
|
|
226
|
+
* @param text The text the conflict's range now holds.
|
|
227
|
+
* @returns {@link ConflictState.Suggested} when it equals the suggestion;
|
|
228
|
+
* otherwise the first match of our text, their text, both ours first, and
|
|
229
|
+
* both theirs first; otherwise {@link ConflictState.Unresolved} when it is
|
|
230
|
+
* still the base text, or {@link ConflictState.Edited}.
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* import { ConflictState, MergeConflict } from "@noldova/code.editor.merge";
|
|
234
|
+
*
|
|
235
|
+
* const conflict = new MergeConflict(0, "b\n", "X\n", "Y\n", 0, 2);
|
|
236
|
+
* conflict.stateFor("Y\n") === ConflictState.Theirs; // true
|
|
237
|
+
* conflict.stateFor("b\n") === ConflictState.Unresolved; // true
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
stateFor(text: string): ConflictState;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A three-way merge being resolved: a document holding the merged text and its
|
|
245
|
+
* conflicts, which follow the edits made to it.
|
|
246
|
+
*
|
|
247
|
+
* @remarks
|
|
248
|
+
* Each conflict starts out holding its base text. A conflict is resolved by
|
|
249
|
+
* accepting a side, by setting its text, or by editing the document; its
|
|
250
|
+
* state is worked out from the text it holds at the time. Every edit goes
|
|
251
|
+
* through {@link MergeDocument.history}, so each can be undone.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* import { ConflictChoice, MergeDocument } from "@noldova/code.editor.merge";
|
|
256
|
+
*
|
|
257
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
258
|
+
* merge.unresolvedCount(); // 1
|
|
259
|
+
* merge.accept(0, ConflictChoice.Theirs, Date.now());
|
|
260
|
+
* merge.document.text(); // "c\n"
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
export declare class MergeDocument {
|
|
264
|
+
/**
|
|
265
|
+
* The merged text being resolved. Editing it directly also moves the
|
|
266
|
+
* conflicts, but bypasses the undo history.
|
|
267
|
+
*/
|
|
268
|
+
readonly document: TextDocument;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The undo history of {@link MergeDocument.document}, which every edit made
|
|
272
|
+
* through this merge goes into.
|
|
273
|
+
*/
|
|
274
|
+
readonly history: UndoHistory;
|
|
275
|
+
|
|
276
|
+
private constructor();
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Merges three versions of a text line by line.
|
|
280
|
+
*
|
|
281
|
+
* @param base The common ancestor.
|
|
282
|
+
* @param ours Our version.
|
|
283
|
+
* @param theirs Their version.
|
|
284
|
+
* @returns A merge whose text takes each region changed on one side only
|
|
285
|
+
* from that side, and holds the base text in each region changed on both
|
|
286
|
+
* sides, which becomes a conflict.
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* import { MergeDocument } from "@noldova/code.editor.merge";
|
|
290
|
+
*
|
|
291
|
+
* const merge = MergeDocument.fromSides("a\nb\n", "A\nb\n", "a\nB\n");
|
|
292
|
+
* merge.conflicts.count(); // 0: each line changed on one side only.
|
|
293
|
+
* merge.document.text(); // "A\nB\n"
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
static fromSides(base: string, ours: string, theirs: string): MergeDocument;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Reads a text with conflict markers, failing on a malformed one.
|
|
300
|
+
*
|
|
301
|
+
* @param merged Text with `<<<<<<<`, `|||||||`, `=======` and `>>>>>>>`
|
|
302
|
+
* marker lines; a conflict without the base section has an empty base.
|
|
303
|
+
* @returns A merge whose text keeps the lines outside the markers and holds
|
|
304
|
+
* each conflict's base text in its place.
|
|
305
|
+
* @throws {ConflictMarkersException} When a marker is out of order or a
|
|
306
|
+
* conflict is never closed.
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* import { MergeDocument } from "@noldova/code.editor.merge";
|
|
310
|
+
*
|
|
311
|
+
* const merge = MergeDocument.fromMarkers("<<<<<<< ours\nb\n=======\nc\n>>>>>>> theirs\n");
|
|
312
|
+
* merge.conflicts.get(0).ours; // "b\n"
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
static fromMarkers(merged: string): MergeDocument;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Reads a text with conflict markers, returning the failure instead of
|
|
319
|
+
* throwing it.
|
|
320
|
+
*
|
|
321
|
+
* @param merged Text with conflict marker lines, as {@link MergeDocument.fromMarkers} reads it.
|
|
322
|
+
* @returns The merge, or the {@link ConflictMarkersException} that
|
|
323
|
+
* {@link MergeDocument.fromMarkers} would throw, naming the 1-based line.
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* import { ConflictMarkersException, MergeDocument } from "@noldova/code.editor.merge";
|
|
327
|
+
*
|
|
328
|
+
* const read = MergeDocument.readMarkers("<<<<<<< ours\nb\n");
|
|
329
|
+
* if (read instanceof ConflictMarkersException)
|
|
330
|
+
* console.log(read.line); // 1: the unclosed conflict's first line.
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
static readMarkers(merged: string): MergeDocument | ConflictMarkersException;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The conflicts, in document order; each one's index is its place in this
|
|
337
|
+
* list. The list never changes, but each conflict's offsets move with the
|
|
338
|
+
* document's edits.
|
|
339
|
+
*/
|
|
340
|
+
get conflicts(): IReadOnlyList<MergeConflict>;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Reads the text a conflict holds now.
|
|
344
|
+
*
|
|
345
|
+
* @param index The conflict's index in {@link MergeDocument.conflicts}.
|
|
346
|
+
* @returns The document text between the conflict's current offsets.
|
|
347
|
+
* @throws {ArgumentOutOfRangeException} When no conflict has that index.
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* import { MergeDocument } from "@noldova/code.editor.merge";
|
|
351
|
+
*
|
|
352
|
+
* MergeDocument.fromSides("a\n", "b\n", "c\n").conflictText(0); // "a\n": the base.
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
conflictText(index: number): string;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Works out how a conflict stands from the text it holds.
|
|
359
|
+
*
|
|
360
|
+
* @param index The conflict's index in {@link MergeDocument.conflicts}.
|
|
361
|
+
* @returns {@link ConflictState.Suggested} when the text equals the last
|
|
362
|
+
* text set with {@link MergeDocument.setConflictText}; otherwise the side or
|
|
363
|
+
* combination it equals, {@link ConflictState.Unresolved} for the base, or
|
|
364
|
+
* {@link ConflictState.Edited} for anything else.
|
|
365
|
+
* @throws {ArgumentOutOfRangeException} When no conflict has that index.
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* import { ConflictChoice, MergeDocument } from "@noldova/code.editor.merge";
|
|
369
|
+
*
|
|
370
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
371
|
+
* merge.accept(0, ConflictChoice.Ours, 0);
|
|
372
|
+
* merge.stateOf(0); // ConflictState.Ours
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
stateOf(index: number): ConflictState;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Counts the unresolved conflicts: those that hold their base text and match
|
|
379
|
+
* no suggestion, side or combination, so base text equal to ours counts as
|
|
380
|
+
* resolved.
|
|
381
|
+
*
|
|
382
|
+
* @returns The number of conflicts whose state is
|
|
383
|
+
* {@link ConflictState.Unresolved}; zero when the merge is resolved.
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* import { MergeDocument } from "@noldova/code.editor.merge";
|
|
387
|
+
*
|
|
388
|
+
* MergeDocument.fromSides("a\n", "b\n", "c\n").unresolvedCount(); // 1
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
unresolvedCount(): number;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Finds the conflict at an offset.
|
|
395
|
+
*
|
|
396
|
+
* @param offset An offset in the document, in UTF-16 code units.
|
|
397
|
+
* @returns The index of the first conflict whose current start is at or
|
|
398
|
+
* before the offset and whose end is at or after it, both ends inclusive;
|
|
399
|
+
* null when none is.
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* import { MergeDocument } from "@noldova/code.editor.merge";
|
|
403
|
+
*
|
|
404
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
405
|
+
* merge.conflictAt(0); // 0
|
|
406
|
+
* merge.conflictAt(9); // null
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
conflictAt(offset: number): number | null;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Replaces a conflict's text with a side or a combination of both sides.
|
|
413
|
+
*
|
|
414
|
+
* @param index The conflict's index in {@link MergeDocument.conflicts}.
|
|
415
|
+
* @param choice The side or combination to take. The combinations put a
|
|
416
|
+
* line feed between the sides when the first one doesn't end in a line ending.
|
|
417
|
+
* @param time The edit's time in milliseconds, kept in the undo history.
|
|
418
|
+
* @returns The document change; undoing it restores the previous text.
|
|
419
|
+
* @throws {ArgumentOutOfRangeException} When no conflict has that index.
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* import { ConflictChoice, MergeDocument } from "@noldova/code.editor.merge";
|
|
423
|
+
*
|
|
424
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
425
|
+
* merge.accept(0, ConflictChoice.BothOursFirst, Date.now());
|
|
426
|
+
* merge.document.text(); // "b\nc\n"
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
accept(index: number, choice: ConflictChoice, time: number): TextChange;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Replaces every unresolved conflict's text with a side or a combination, as
|
|
433
|
+
* one change.
|
|
434
|
+
*
|
|
435
|
+
* @param choice The side or combination to take for each unresolved conflict.
|
|
436
|
+
* @param time The edit's time in milliseconds, kept in the undo history.
|
|
437
|
+
* @returns The document change, undone as one step; null when no conflict
|
|
438
|
+
* is unresolved, leaving the document unchanged.
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* import { ConflictChoice, MergeDocument } from "@noldova/code.editor.merge";
|
|
442
|
+
*
|
|
443
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
444
|
+
* merge.acceptAll(ConflictChoice.Ours, Date.now());
|
|
445
|
+
* merge.acceptAll(ConflictChoice.Ours, Date.now()); // null: none left.
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
acceptAll(choice: ConflictChoice, time: number): TextChange | null;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Sets a conflict's text, such as a suggested resolution, and remembers it
|
|
452
|
+
* as the conflict's suggestion.
|
|
453
|
+
*
|
|
454
|
+
* @param index The conflict's index in {@link MergeDocument.conflicts}.
|
|
455
|
+
* @param text The resolved text; while the conflict holds it, its state is
|
|
456
|
+
* {@link ConflictState.Suggested}.
|
|
457
|
+
* @param time The edit's time in milliseconds, kept in the undo history.
|
|
458
|
+
* @returns The document change.
|
|
459
|
+
* @throws {ArgumentOutOfRangeException} When no conflict has that index.
|
|
460
|
+
* @example
|
|
461
|
+
* ```ts
|
|
462
|
+
* import { MergeDocument } from "@noldova/code.editor.merge";
|
|
463
|
+
*
|
|
464
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
465
|
+
* merge.setConflictText(0, "bc\n", Date.now());
|
|
466
|
+
* merge.stateOf(0); // ConflictState.Suggested
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
setConflictText(index: number, text: string, time: number): TextChange;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Puts a conflict's base text back, which makes it unresolved again unless
|
|
473
|
+
* the base equals one of its sides or its suggestion.
|
|
474
|
+
*
|
|
475
|
+
* @param index The conflict's index in {@link MergeDocument.conflicts}.
|
|
476
|
+
* @param time The edit's time in milliseconds, kept in the undo history.
|
|
477
|
+
* @returns The document change; a change is made even when the text was
|
|
478
|
+
* already the base.
|
|
479
|
+
* @throws {ArgumentOutOfRangeException} When no conflict has that index.
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* import { ConflictChoice, MergeDocument } from "@noldova/code.editor.merge";
|
|
483
|
+
*
|
|
484
|
+
* const merge = MergeDocument.fromSides("a\n", "b\n", "c\n");
|
|
485
|
+
* merge.accept(0, ConflictChoice.Ours, 0);
|
|
486
|
+
* merge.reset(0, 1);
|
|
487
|
+
* merge.unresolvedCount(); // 1
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
reset(index: number, time: number): TextChange;
|
|
491
|
+
}
|
package/api/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { ConflictChoice } from "../enums/conflict-choice.js";
|
|
9
|
+
export { ConflictState } from "../enums/conflict-state.js";
|
|
10
|
+
export { ConflictMarkersException } from "../exceptions/conflict-markers.exception.js";
|
|
11
|
+
export { MergeConflict } from "../models/merge-conflict.js";
|
|
12
|
+
export { MergeDocument } from "../services/merge-document.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export var ConflictChoice;
|
|
9
|
+
(function (ConflictChoice) {
|
|
10
|
+
ConflictChoice["Ours"] = "Ours";
|
|
11
|
+
ConflictChoice["Theirs"] = "Theirs";
|
|
12
|
+
ConflictChoice["BothOursFirst"] = "BothOursFirst";
|
|
13
|
+
ConflictChoice["BothTheirsFirst"] = "BothTheirsFirst";
|
|
14
|
+
})(ConflictChoice || (ConflictChoice = {}));
|
|
15
|
+
//# sourceMappingURL=conflict-choice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-choice.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/enums/conflict-choice.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,+BAAa,CAAA;IACb,mCAAiB,CAAA;IACjB,iDAA+B,CAAA;IAC/B,qDAAmC,CAAA;AACrC,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export var ConflictState;
|
|
9
|
+
(function (ConflictState) {
|
|
10
|
+
ConflictState["Unresolved"] = "Unresolved";
|
|
11
|
+
ConflictState["Ours"] = "Ours";
|
|
12
|
+
ConflictState["Theirs"] = "Theirs";
|
|
13
|
+
ConflictState["BothOursFirst"] = "BothOursFirst";
|
|
14
|
+
ConflictState["BothTheirsFirst"] = "BothTheirsFirst";
|
|
15
|
+
ConflictState["Suggested"] = "Suggested";
|
|
16
|
+
ConflictState["Edited"] = "Edited";
|
|
17
|
+
})(ConflictState || (ConflictState = {}));
|
|
18
|
+
//# sourceMappingURL=conflict-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-state.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/enums/conflict-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,0CAAyB,CAAA;IACzB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,gDAA+B,CAAA;IAC/B,oDAAmC,CAAA;IACnC,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;AACnB,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export var MarkerSection;
|
|
9
|
+
(function (MarkerSection) {
|
|
10
|
+
MarkerSection["Outside"] = "Outside";
|
|
11
|
+
MarkerSection["Ours"] = "Ours";
|
|
12
|
+
MarkerSection["Base"] = "Base";
|
|
13
|
+
MarkerSection["Theirs"] = "Theirs";
|
|
14
|
+
})(MarkerSection || (MarkerSection = {}));
|
|
15
|
+
//# sourceMappingURL=marker-section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-section.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/enums/marker-section.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { Exception } from "@noldova/context.exceptions";
|
|
9
|
+
import { Resources } from "../resources.js";
|
|
10
|
+
export class ConflictMarkersException extends Exception {
|
|
11
|
+
name = Resources.conflictMarkersExceptionName;
|
|
12
|
+
line;
|
|
13
|
+
constructor(line, reason) {
|
|
14
|
+
super(Resources.formatConflictMarkers(line, reason));
|
|
15
|
+
this.line = line;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=conflict-markers.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-markers.exception.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/exceptions/conflict-markers.exception.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IAC5B,IAAI,GAAW,SAAS,CAAC,4BAA4B,CAAC;IAE/D,IAAI,CAAS;IAE7B,YAAmB,IAAY,EAAE,MAAc;QAC7C,KAAK,CAAC,SAAS,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAErD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { ConflictChoice } from "../enums/conflict-choice.js";
|
|
10
|
+
import { ConflictState } from "../enums/conflict-state.js";
|
|
11
|
+
import { Resources } from "../resources.js";
|
|
12
|
+
export class MergeConflict {
|
|
13
|
+
index;
|
|
14
|
+
base;
|
|
15
|
+
ours;
|
|
16
|
+
theirs;
|
|
17
|
+
startOffset;
|
|
18
|
+
endOffset;
|
|
19
|
+
suggested = null;
|
|
20
|
+
constructor(index, base, ours, theirs, start, end) {
|
|
21
|
+
this.index = index;
|
|
22
|
+
this.base = base;
|
|
23
|
+
this.ours = ours;
|
|
24
|
+
this.theirs = theirs;
|
|
25
|
+
this.startOffset = start;
|
|
26
|
+
this.endOffset = end;
|
|
27
|
+
}
|
|
28
|
+
get start() {
|
|
29
|
+
return this.startOffset;
|
|
30
|
+
}
|
|
31
|
+
get end() {
|
|
32
|
+
return this.endOffset;
|
|
33
|
+
}
|
|
34
|
+
get suggestion() {
|
|
35
|
+
return this.suggested;
|
|
36
|
+
}
|
|
37
|
+
moveTo(start, end) {
|
|
38
|
+
this.startOffset = start;
|
|
39
|
+
this.endOffset = end;
|
|
40
|
+
}
|
|
41
|
+
suggest(text) {
|
|
42
|
+
this.suggested = text;
|
|
43
|
+
}
|
|
44
|
+
choiceText(choice) {
|
|
45
|
+
switch (choice) {
|
|
46
|
+
case ConflictChoice.Ours:
|
|
47
|
+
return this.ours;
|
|
48
|
+
case ConflictChoice.Theirs:
|
|
49
|
+
return this.theirs;
|
|
50
|
+
case ConflictChoice.BothOursFirst:
|
|
51
|
+
return MergeConflict.join(this.ours, this.theirs);
|
|
52
|
+
case ConflictChoice.BothTheirsFirst:
|
|
53
|
+
return MergeConflict.join(this.theirs, this.ours);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
stateFor(text) {
|
|
57
|
+
if (text === this.suggested)
|
|
58
|
+
return ConflictState.Suggested;
|
|
59
|
+
if (text === this.ours)
|
|
60
|
+
return ConflictState.Ours;
|
|
61
|
+
if (text === this.theirs)
|
|
62
|
+
return ConflictState.Theirs;
|
|
63
|
+
if (text === this.choiceText(ConflictChoice.BothOursFirst))
|
|
64
|
+
return ConflictState.BothOursFirst;
|
|
65
|
+
if (text === this.choiceText(ConflictChoice.BothTheirsFirst))
|
|
66
|
+
return ConflictState.BothTheirsFirst;
|
|
67
|
+
return text === this.base ? ConflictState.Unresolved : ConflictState.Edited;
|
|
68
|
+
}
|
|
69
|
+
static join(first, second) {
|
|
70
|
+
return first === String.empty || second === String.empty || Resources.lineEndPattern.test(first)
|
|
71
|
+
? first + second
|
|
72
|
+
: first + Resources.lineFeed + second;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=merge-conflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-conflict.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/models/merge-conflict.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4B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
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class MergeStart {
|
|
9
|
+
text;
|
|
10
|
+
conflicts;
|
|
11
|
+
constructor(text, conflicts) {
|
|
12
|
+
this.text = text;
|
|
13
|
+
this.conflicts = conflicts;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=merge-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-start.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/models/merge-start.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,OAAO,UAAU;IACL,IAAI,CAAS;IACb,SAAS,CAA+B;IAExD,YAAmB,IAAY,EAAE,SAAuC;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/code.editor.merge",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "The code editor's framework-free 3-way merge model: a merge document with per-conflict choices, undo and conflict markers, over the core's text model.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "api/index.js",
|
|
7
|
+
"types": "api/index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/noldova-com/code-editor.git",
|
|
12
|
+
"directory": "src/noldova.code.editor.merge"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/noldova-com/code-editor#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/noldova-com/code-editor/issues"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@noldova/code.editor": "0.0.2",
|
|
24
|
+
"@noldova/diff": "0.0.2"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@noldova/context.collections": ">=0.0.17 <0.1.0",
|
|
28
|
+
"@noldova/context.core": ">=0.0.17 <0.1.0",
|
|
29
|
+
"@noldova/context.exceptions": ">=0.0.17 <0.1.0"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "3d402fbe7f27ad6c31227bc0e9372fa06484a79f"
|
|
32
|
+
}
|
package/resources.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class Resources {
|
|
9
|
+
static lineFeed = "\n";
|
|
10
|
+
static lineEndPattern = /(?:\r\n|\r|\n)$/;
|
|
11
|
+
static markerLength = 7;
|
|
12
|
+
static markerLabelSeparator = " ";
|
|
13
|
+
static oursMarker = "<<<<<<<";
|
|
14
|
+
static baseMarker = "|||||||";
|
|
15
|
+
static theirsMarker = "=======";
|
|
16
|
+
static endMarker = ">>>>>>>";
|
|
17
|
+
static conflictMarkersExceptionName = "ConflictMarkersException";
|
|
18
|
+
static wordSeparator = " ";
|
|
19
|
+
static reasonSeparator = ": ";
|
|
20
|
+
static sentenceEnd = ".";
|
|
21
|
+
static markersDontParse = "The conflict markers don't parse at line";
|
|
22
|
+
static outOfPlace = "is out of place";
|
|
23
|
+
static markerUnclosed = "the conflict that starts here has no end marker";
|
|
24
|
+
static formatConflictMarkers(line, reason) {
|
|
25
|
+
return `${Resources.markersDontParse}${Resources.wordSeparator}${line}${Resources.reasonSeparator}${reason}${Resources.sentenceEnd}`;
|
|
26
|
+
}
|
|
27
|
+
static formatMarkerUnexpected(marker) {
|
|
28
|
+
return `${marker}${Resources.wordSeparator}${Resources.outOfPlace}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=resources.js.map
|
package/resources.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/noldova.code.editor.merge/src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,SAAS;IACb,MAAM,CAAU,QAAQ,GAAW,IAAI,CAAC;IACxC,MAAM,CAAU,cAAc,GAAW,iBAAiB,CAAC;IAC3D,MAAM,CAAU,YAAY,GAAW,CAAC,CAAC;IACzC,MAAM,CAAU,oBAAoB,GAAW,GAAG,CAAC;IACnD,MAAM,CAAU,UAAU,GAAW,SAAS,CAAC;IAC/C,MAAM,CAAU,UAAU,GAAW,SAAS,CAAC;IAC/C,MAAM,CAAU,YAAY,GAAW,SAAS,CAAC;IACjD,MAAM,CAAU,SAAS,GAAW,SAAS,CAAC;IAC9C,MAAM,CAAU,4BAA4B,GAAW,0BAA0B,CAAC;IAClF,MAAM,CAAU,aAAa,GAAW,GAAG,CAAC;IAC5C,MAAM,CAAU,eAAe,GAAW,IAAI,CAAC;IAC/C,MAAM,CAAU,WAAW,GAAW,GAAG,CAAC;IAC1C,MAAM,CAAU,gBAAgB,GAAW,0CAA0C,CAAC;IACtF,MAAM,CAAU,UAAU,GAAW,iBAAiB,CAAC;IACvD,MAAM,CAAU,cAAc,GAAW,iDAAiD,CAAC;IAE3F,MAAM,CAAC,qBAAqB,CAAC,IAAY,EAAE,MAAc;QAC9D,OAAO,GAAG,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAC,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IACvI,CAAC;IAEM,MAAM,CAAC,sBAAsB,CAAC,MAAc;QACjD,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;IACtE,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { LineSplit } from "@noldova/code.editor";
|
|
10
|
+
import { List } from "@noldova/context.collections";
|
|
11
|
+
import { MarkerSection } from "../enums/marker-section.js";
|
|
12
|
+
import { ConflictMarkersException } from "../exceptions/conflict-markers.exception.js";
|
|
13
|
+
import { MergeConflict } from "../models/merge-conflict.js";
|
|
14
|
+
import { MergeStart } from "../models/merge-start.js";
|
|
15
|
+
import { Resources } from "../resources.js";
|
|
16
|
+
export class ConflictMarkers {
|
|
17
|
+
static MARKERS = [Resources.oursMarker, Resources.baseMarker, Resources.theirsMarker, Resources.endMarker];
|
|
18
|
+
static parse(merged) {
|
|
19
|
+
const start = ConflictMarkers.read(merged);
|
|
20
|
+
if (start instanceof ConflictMarkersException)
|
|
21
|
+
throw start;
|
|
22
|
+
return start;
|
|
23
|
+
}
|
|
24
|
+
static read(merged) {
|
|
25
|
+
const split = LineSplit.of(merged);
|
|
26
|
+
const parts = [];
|
|
27
|
+
const conflicts = new List();
|
|
28
|
+
let section = MarkerSection.Outside;
|
|
29
|
+
let ours = [];
|
|
30
|
+
let base = [];
|
|
31
|
+
let theirs = [];
|
|
32
|
+
let offset = 0;
|
|
33
|
+
let startLine = 0;
|
|
34
|
+
for (let index = 0; index < split.texts.count(); index++) {
|
|
35
|
+
const text = split.texts.get(index);
|
|
36
|
+
const line = text + split.endings.get(index);
|
|
37
|
+
const found = ConflictMarkers.markerOf(text);
|
|
38
|
+
const marker = section === MarkerSection.Outside && found !== Resources.oursMarker ? null : found;
|
|
39
|
+
const expected = ConflictMarkers.next(section, marker);
|
|
40
|
+
if (!Object.isNull(marker) && Object.isNull(expected))
|
|
41
|
+
return new ConflictMarkersException(index + 1, Resources.formatMarkerUnexpected(marker));
|
|
42
|
+
if (marker === Resources.oursMarker) {
|
|
43
|
+
section = MarkerSection.Ours;
|
|
44
|
+
startLine = index;
|
|
45
|
+
}
|
|
46
|
+
else if (marker === Resources.baseMarker)
|
|
47
|
+
section = MarkerSection.Base;
|
|
48
|
+
else if (marker === Resources.theirsMarker)
|
|
49
|
+
section = MarkerSection.Theirs;
|
|
50
|
+
else if (marker === Resources.endMarker) {
|
|
51
|
+
const baseText = base.join(String.empty);
|
|
52
|
+
conflicts.add(new MergeConflict(conflicts.count(), baseText, ours.join(String.empty), theirs.join(String.empty), offset, offset + baseText.length));
|
|
53
|
+
parts.push(baseText);
|
|
54
|
+
offset += baseText.length;
|
|
55
|
+
ours = [];
|
|
56
|
+
base = [];
|
|
57
|
+
theirs = [];
|
|
58
|
+
section = MarkerSection.Outside;
|
|
59
|
+
}
|
|
60
|
+
else if (section === MarkerSection.Ours)
|
|
61
|
+
ours.push(line);
|
|
62
|
+
else if (section === MarkerSection.Base)
|
|
63
|
+
base.push(line);
|
|
64
|
+
else if (section === MarkerSection.Theirs)
|
|
65
|
+
theirs.push(line);
|
|
66
|
+
else {
|
|
67
|
+
parts.push(line);
|
|
68
|
+
offset += line.length;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (section !== MarkerSection.Outside)
|
|
72
|
+
return new ConflictMarkersException(startLine + 1, Resources.markerUnclosed);
|
|
73
|
+
return new MergeStart(parts.join(String.empty), conflicts);
|
|
74
|
+
}
|
|
75
|
+
static markerOf(text) {
|
|
76
|
+
const marker = ConflictMarkers.MARKERS.find(t => text.startsWith(t));
|
|
77
|
+
if (Object.isUndefined(marker))
|
|
78
|
+
return null;
|
|
79
|
+
return text.length === Resources.markerLength || text.charAt(Resources.markerLength) === Resources.markerLabelSeparator ? marker : null;
|
|
80
|
+
}
|
|
81
|
+
static next(section, marker) {
|
|
82
|
+
switch (section) {
|
|
83
|
+
case MarkerSection.Outside:
|
|
84
|
+
return marker;
|
|
85
|
+
case MarkerSection.Ours:
|
|
86
|
+
return marker === Resources.baseMarker || marker === Resources.theirsMarker ? marker : null;
|
|
87
|
+
case MarkerSection.Base:
|
|
88
|
+
return marker === Resources.theirsMarker ? marker : null;
|
|
89
|
+
case MarkerSection.Theirs:
|
|
90
|
+
return marker === Resources.endMarker ? marker : null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=conflict-markers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-markers.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/services/conflict-markers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,eAAe;IAClB,MAAM,CAAU,OAAO,GAAsB,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAExI,MAAM,CAAC,KAAK,CAAC,MAAc;QAChC,MAAM,KAAK,GAA0C,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,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AAI;gBACrB,OAAO,MAAM,KAAK,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3D,KAAK,aAAa,CAAC,MAAM;gBACvB,OAAO,MAAM,KAAK,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1D,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { EditKind, EditTransaction, LineSplit, TextDocument, TextEdit, TextPosition, TextRange, TextSelection, UndoHistory } from "@noldova/code.editor";
|
|
10
|
+
import { List } from "@noldova/context.collections";
|
|
11
|
+
import { Merge3, MergeRegionKind } from "@noldova/diff";
|
|
12
|
+
import { ConflictChoice } from "../enums/conflict-choice.js";
|
|
13
|
+
import { ConflictState } from "../enums/conflict-state.js";
|
|
14
|
+
import { ConflictMarkersException } from "../exceptions/conflict-markers.exception.js";
|
|
15
|
+
import { MergeConflict } from "../models/merge-conflict.js";
|
|
16
|
+
import { MergeStart } from "../models/merge-start.js";
|
|
17
|
+
import { ConflictMarkers } from "./conflict-markers.js";
|
|
18
|
+
export class MergeDocument {
|
|
19
|
+
document;
|
|
20
|
+
history;
|
|
21
|
+
conflictList;
|
|
22
|
+
constructor(start) {
|
|
23
|
+
this.document = TextDocument.fromText(start.text);
|
|
24
|
+
this.history = new UndoHistory(this.document);
|
|
25
|
+
this.conflictList = start.conflicts;
|
|
26
|
+
this.document.onChange(t => this.follow(t));
|
|
27
|
+
}
|
|
28
|
+
static fromSides(base, ours, theirs) {
|
|
29
|
+
const baseLines = MergeDocument.lines(base);
|
|
30
|
+
const oursLines = MergeDocument.lines(ours);
|
|
31
|
+
const theirsLines = MergeDocument.lines(theirs);
|
|
32
|
+
const parts = [];
|
|
33
|
+
const conflicts = new List();
|
|
34
|
+
let offset = 0;
|
|
35
|
+
for (const region of Merge3.lines(baseLines, oursLines, theirsLines)) {
|
|
36
|
+
const baseText = baseLines.slice(region.baseStart, region.baseEnd).join(String.empty);
|
|
37
|
+
const oursText = oursLines.slice(region.oursStart, region.oursEnd).join(String.empty);
|
|
38
|
+
const theirsText = theirsLines.slice(region.theirsStart, region.theirsEnd).join(String.empty);
|
|
39
|
+
if (region.kind === MergeRegionKind.Conflict)
|
|
40
|
+
conflicts.add(new MergeConflict(conflicts.count(), baseText, oursText, theirsText, offset, offset + baseText.length));
|
|
41
|
+
const text = region.kind === MergeRegionKind.Theirs ? theirsText : region.kind === MergeRegionKind.Conflict ? baseText : oursText;
|
|
42
|
+
parts.push(text);
|
|
43
|
+
offset += text.length;
|
|
44
|
+
}
|
|
45
|
+
return new MergeDocument(new MergeStart(parts.join(String.empty), conflicts));
|
|
46
|
+
}
|
|
47
|
+
static fromMarkers(merged) {
|
|
48
|
+
return new MergeDocument(ConflictMarkers.parse(merged));
|
|
49
|
+
}
|
|
50
|
+
static readMarkers(merged) {
|
|
51
|
+
const start = ConflictMarkers.read(merged);
|
|
52
|
+
return start instanceof ConflictMarkersException ? start : new MergeDocument(start);
|
|
53
|
+
}
|
|
54
|
+
get conflicts() {
|
|
55
|
+
return this.conflictList;
|
|
56
|
+
}
|
|
57
|
+
conflictText(index) {
|
|
58
|
+
const conflict = this.conflictList.get(index);
|
|
59
|
+
return this.document.textBetween(conflict.start, conflict.end);
|
|
60
|
+
}
|
|
61
|
+
stateOf(index) {
|
|
62
|
+
return this.conflictList.get(index).stateFor(this.conflictText(index));
|
|
63
|
+
}
|
|
64
|
+
unresolvedCount() {
|
|
65
|
+
return this.conflictList.count(t => this.stateOf(t.index) === ConflictState.Unresolved);
|
|
66
|
+
}
|
|
67
|
+
conflictAt(offset) {
|
|
68
|
+
return this.conflictList.firstOrDefault(t => t.start <= offset && offset <= t.end)?.index ?? null;
|
|
69
|
+
}
|
|
70
|
+
accept(index, choice, time) {
|
|
71
|
+
return this.replace(this.conflictList.get(index), this.conflictList.get(index).choiceText(choice), time);
|
|
72
|
+
}
|
|
73
|
+
acceptAll(choice, time) {
|
|
74
|
+
const open = this.conflictList.where(t => this.stateOf(t.index) === ConflictState.Unresolved).toList();
|
|
75
|
+
if (!open.any())
|
|
76
|
+
return null;
|
|
77
|
+
const edits = open.select(t => new TextEdit(new TextRange(this.document.positionAt(t.start), this.document.positionAt(t.end)), t.choiceText(choice))).toList();
|
|
78
|
+
const caret = this.document.positionAt(open.get(0).start);
|
|
79
|
+
return this.history.apply(new EditTransaction(edits, EditKind.Other, time, new List([new TextSelection(caret)]), new List([new TextSelection(caret)])));
|
|
80
|
+
}
|
|
81
|
+
setConflictText(index, text, time) {
|
|
82
|
+
const conflict = this.conflictList.get(index);
|
|
83
|
+
conflict.suggest(text);
|
|
84
|
+
return this.replace(conflict, text, time);
|
|
85
|
+
}
|
|
86
|
+
reset(index, time) {
|
|
87
|
+
const conflict = this.conflictList.get(index);
|
|
88
|
+
return this.replace(conflict, conflict.base, time);
|
|
89
|
+
}
|
|
90
|
+
replace(conflict, text, time) {
|
|
91
|
+
const range = new TextRange(this.document.positionAt(conflict.start), this.document.positionAt(conflict.end));
|
|
92
|
+
const inserted = LineSplit.of(text);
|
|
93
|
+
const count = inserted.texts.count();
|
|
94
|
+
const last = inserted.texts.get(count - 1);
|
|
95
|
+
const end = count === 1
|
|
96
|
+
? new TextPosition(range.start.line, range.start.column + last.length)
|
|
97
|
+
: new TextPosition(range.start.line + count - 1, last.length);
|
|
98
|
+
const change = this.history.apply(new EditTransaction(new List([new TextEdit(range, text)]), EditKind.Other, time, new List([new TextSelection(range.start)]), new List([new TextSelection(end)])));
|
|
99
|
+
return change;
|
|
100
|
+
}
|
|
101
|
+
follow(change) {
|
|
102
|
+
for (const conflict of this.conflictList) {
|
|
103
|
+
const isEmpty = conflict.start === conflict.end;
|
|
104
|
+
conflict.moveTo(MergeDocument.mapStart(conflict.start, isEmpty, change.edits), MergeDocument.mapEnd(conflict.end, isEmpty, change.edits));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
static mapStart(position, isEmpty, edits) {
|
|
108
|
+
let delta = 0;
|
|
109
|
+
for (const edit of edits) {
|
|
110
|
+
const end = edit.oldOffset + edit.oldText.length;
|
|
111
|
+
if (end < position || (end === position && (!String.isNullOrEmpty(edit.oldText) || !isEmpty)))
|
|
112
|
+
delta += edit.text.length - edit.oldText.length;
|
|
113
|
+
else if (edit.oldOffset < position)
|
|
114
|
+
return edit.oldOffset + delta;
|
|
115
|
+
else
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
return position + delta;
|
|
119
|
+
}
|
|
120
|
+
static mapEnd(position, isEmpty, edits) {
|
|
121
|
+
let delta = 0;
|
|
122
|
+
for (const edit of edits) {
|
|
123
|
+
const end = edit.oldOffset + edit.oldText.length;
|
|
124
|
+
if (end < position || (end === position && (!String.isNullOrEmpty(edit.oldText) || isEmpty)))
|
|
125
|
+
delta += edit.text.length - edit.oldText.length;
|
|
126
|
+
else if (edit.oldOffset < position)
|
|
127
|
+
return edit.oldOffset + delta + edit.text.length;
|
|
128
|
+
else
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
return position + delta;
|
|
132
|
+
}
|
|
133
|
+
static lines(text) {
|
|
134
|
+
const split = LineSplit.of(text);
|
|
135
|
+
const lines = split.texts.select((t, i) => t + split.endings.get(i)).toArray();
|
|
136
|
+
return lines.at(-1) === String.empty ? lines.slice(0, -1) : lines;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=merge-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-document.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor.merge/src/services/merge-document.ts"],"names":[],"mappings":"AAAA;;;;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