@@ -17,7 +17,7 @@ export class LineEdit {
17
17
public static readonly empty = new LineEdit ( [ ] ) ;
18
18
19
19
public static deserialize ( data : SerializedLineEdit ) : LineEdit {
20
- return new LineEdit ( data . map ( e => SingleLineEdit . deserialize ( e ) ) ) ;
20
+ return new LineEdit ( data . map ( e => LineReplacement . deserialize ( e ) ) ) ;
21
21
}
22
22
23
23
public static fromEdit ( edit : StringEdit , initialValue : AbstractText ) : LineEdit {
@@ -28,7 +28,7 @@ export class LineEdit {
28
28
public static fromTextEdit ( edit : TextEdit , initialValue : AbstractText ) : LineEdit {
29
29
const edits = edit . replacements ;
30
30
31
- const result : SingleLineEdit [ ] = [ ] ;
31
+ const result : LineReplacement [ ] = [ ] ;
32
32
33
33
const currentEdits : TextReplacement [ ] = [ ] ;
34
34
for ( let i = 0 ; i < edits . length ; i ++ ) {
@@ -42,14 +42,14 @@ export class LineEdit {
42
42
const singleEdit = TextReplacement . joinReplacements ( currentEdits , initialValue ) ;
43
43
currentEdits . length = 0 ;
44
44
45
- const singleLineEdit = SingleLineEdit . fromSingleTextEdit ( singleEdit , initialValue ) ;
45
+ const singleLineEdit = LineReplacement . fromSingleTextEdit ( singleEdit , initialValue ) ;
46
46
result . push ( singleLineEdit ) ;
47
47
}
48
48
49
49
return new LineEdit ( result ) ;
50
50
}
51
51
52
- public static createFromUnsorted ( edits : readonly SingleLineEdit [ ] ) : LineEdit {
52
+ public static createFromUnsorted ( edits : readonly LineReplacement [ ] ) : LineEdit {
53
53
const result = edits . slice ( ) ;
54
54
result . sort ( compareBy ( i => i . lineRange . startLineNumber , numberComparator ) ) ;
55
55
return new LineEdit ( result ) ;
@@ -59,7 +59,7 @@ export class LineEdit {
59
59
/**
60
60
* Have to be sorted by start line number and non-intersecting.
61
61
*/
62
- public readonly edits : readonly SingleLineEdit [ ]
62
+ public readonly edits : readonly LineReplacement [ ]
63
63
) {
64
64
assert ( checkAdjacentItems ( edits , ( i1 , i2 ) => i1 . lineRange . endLineNumberExclusive <= i2 . lineRange . startLineNumber ) ) ;
65
65
}
@@ -112,7 +112,7 @@ export class LineEdit {
112
112
113
113
public rebase ( base : LineEdit ) : LineEdit {
114
114
return new LineEdit (
115
- this . edits . map ( e => new SingleLineEdit ( base . mapLineRange ( e . lineRange ) , e . newLines ) ) ,
115
+ this . edits . map ( e => new LineReplacement ( base . mapLineRange ( e . lineRange ) , e . newLines ) ) ,
116
116
) ;
117
117
}
118
118
@@ -208,15 +208,15 @@ export class LineEdit {
208
208
}
209
209
}
210
210
211
- export class SingleLineEdit {
212
- public static deserialize ( e : SerializedSingleLineEdit ) : SingleLineEdit {
213
- return new SingleLineEdit (
211
+ export class LineReplacement {
212
+ public static deserialize ( e : SerializedSingleLineEdit ) : LineReplacement {
213
+ return new LineReplacement (
214
214
LineRange . ofLength ( e [ 0 ] , e [ 1 ] - e [ 0 ] ) ,
215
215
e [ 2 ] ,
216
216
) ;
217
217
}
218
218
219
- public static fromSingleTextEdit ( edit : TextReplacement , initialValue : AbstractText ) : SingleLineEdit {
219
+ public static fromSingleTextEdit ( edit : TextReplacement , initialValue : AbstractText ) : LineReplacement {
220
220
// 1: ab[cde
221
221
// 2: fghijk
222
222
// 3: lmn]opq
@@ -262,7 +262,7 @@ export class SingleLineEdit {
262
262
newLines . pop ( ) ;
263
263
}
264
264
265
- return new SingleLineEdit ( new LineRange ( startLineNumber , endLineNumberEx ) , newLines ) ;
265
+ return new LineReplacement ( new LineRange ( startLineNumber , endLineNumberEx ) , newLines ) ;
266
266
}
267
267
268
268
constructor (
@@ -343,7 +343,7 @@ export class SingleLineEdit {
343
343
] ;
344
344
}
345
345
346
- public removeCommonSuffixPrefixLines ( initialValue : AbstractText ) : SingleLineEdit {
346
+ public removeCommonSuffixPrefixLines ( initialValue : AbstractText ) : LineReplacement {
347
347
let startLineNumber = this . lineRange . startLineNumber ;
348
348
let endLineNumberEx = this . lineRange . endLineNumberExclusive ;
349
349
@@ -368,7 +368,7 @@ export class SingleLineEdit {
368
368
if ( trimStartCount === 0 && trimEndCount === 0 ) {
369
369
return this ;
370
370
}
371
- return new SingleLineEdit ( new LineRange ( startLineNumber , endLineNumberEx ) , this . newLines . slice ( trimStartCount , this . newLines . length - trimEndCount ) ) ;
371
+ return new LineReplacement ( new LineRange ( startLineNumber , endLineNumberEx ) , this . newLines . slice ( trimStartCount , this . newLines . length - trimEndCount ) ) ;
372
372
}
373
373
374
374
public toLineEdit ( ) : LineEdit {
0 commit comments