@@ -228,9 +228,8 @@ namespace ts.textChanges {
228
228
/** Public for tests only. Other callers should use `ChangeTracker.with`. */
229
229
constructor ( private readonly newLineCharacter : string , private readonly formatContext : formatting . FormatContext ) { }
230
230
231
- public deleteRange ( sourceFile : SourceFile , range : TextRange ) {
231
+ public deleteRange ( sourceFile : SourceFile , range : TextRange ) : void {
232
232
this . changes . push ( { kind : ChangeKind . Remove , sourceFile, range } ) ;
233
- return this ;
234
233
}
235
234
236
235
delete ( sourceFile : SourceFile , node : Node | NodeArray < TypeParameterDeclaration > ) : void {
@@ -241,11 +240,10 @@ namespace ts.textChanges {
241
240
this . deleteRange ( sourceFile , { pos : modifier . getStart ( sourceFile ) , end : skipTrivia ( sourceFile . text , modifier . end , /*stopAfterLineBreak*/ true ) } ) ;
242
241
}
243
242
244
- public deleteNodeRange ( sourceFile : SourceFile , startNode : Node , endNode : Node , options : ConfigurableStartEnd = { } ) {
243
+ public deleteNodeRange ( sourceFile : SourceFile , startNode : Node , endNode : Node , options : ConfigurableStartEnd = { } ) : void {
245
244
const startPosition = getAdjustedStartPosition ( sourceFile , startNode , options , Position . FullStart ) ;
246
245
const endPosition = getAdjustedEndPosition ( sourceFile , endNode , options ) ;
247
246
this . deleteRange ( sourceFile , { pos : startPosition , end : endPosition } ) ;
248
- return this ;
249
247
}
250
248
251
249
public deleteNodeRangeExcludingEnd ( sourceFile : SourceFile , startNode : Node , afterEndNode : Node | undefined , options : ConfigurableStartEnd = { } ) : void {
@@ -254,47 +252,45 @@ namespace ts.textChanges {
254
252
this . deleteRange ( sourceFile , { pos : startPosition , end : endPosition } ) ;
255
253
}
256
254
257
- public replaceRange ( sourceFile : SourceFile , range : TextRange , newNode : Node , options : InsertNodeOptions = { } ) {
255
+ public replaceRange ( sourceFile : SourceFile , range : TextRange , newNode : Node , options : InsertNodeOptions = { } ) : void {
258
256
this . changes . push ( { kind : ChangeKind . ReplaceWithSingleNode , sourceFile, range, options, node : newNode } ) ;
259
- return this ;
260
257
}
261
258
262
- public replaceNode ( sourceFile : SourceFile , oldNode : Node , newNode : Node , options : ChangeNodeOptions = useNonAdjustedPositions ) {
263
- return this . replaceRange ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , options ) , newNode , options ) ;
259
+ public replaceNode ( sourceFile : SourceFile , oldNode : Node , newNode : Node , options : ChangeNodeOptions = useNonAdjustedPositions ) : void {
260
+ this . replaceRange ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , options ) , newNode , options ) ;
264
261
}
265
262
266
- public replaceNodeRange ( sourceFile : SourceFile , startNode : Node , endNode : Node , newNode : Node , options : ChangeNodeOptions = useNonAdjustedPositions ) {
263
+ public replaceNodeRange ( sourceFile : SourceFile , startNode : Node , endNode : Node , newNode : Node , options : ChangeNodeOptions = useNonAdjustedPositions ) : void {
267
264
this . replaceRange ( sourceFile , getAdjustedRange ( sourceFile , startNode , endNode , options ) , newNode , options ) ;
268
265
}
269
266
270
- private replaceRangeWithNodes ( sourceFile : SourceFile , range : TextRange , newNodes : ReadonlyArray < Node > , options : ReplaceWithMultipleNodesOptions & ConfigurableStartEnd = { } ) {
267
+ private replaceRangeWithNodes ( sourceFile : SourceFile , range : TextRange , newNodes : ReadonlyArray < Node > , options : ReplaceWithMultipleNodesOptions & ConfigurableStartEnd = { } ) : void {
271
268
this . changes . push ( { kind : ChangeKind . ReplaceWithMultipleNodes , sourceFile, range, options, nodes : newNodes } ) ;
272
- return this ;
273
269
}
274
270
275
- public replaceNodeWithNodes ( sourceFile : SourceFile , oldNode : Node , newNodes : ReadonlyArray < Node > , options : ChangeNodeOptions = useNonAdjustedPositions ) {
276
- return this . replaceRangeWithNodes ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , options ) , newNodes , options ) ;
271
+ public replaceNodeWithNodes ( sourceFile : SourceFile , oldNode : Node , newNodes : ReadonlyArray < Node > , options : ChangeNodeOptions = useNonAdjustedPositions ) : void {
272
+ this . replaceRangeWithNodes ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , options ) , newNodes , options ) ;
277
273
}
278
274
279
275
public replaceNodeWithText ( sourceFile : SourceFile , oldNode : Node , text : string ) : void {
280
276
this . replaceRangeWithText ( sourceFile , getAdjustedRange ( sourceFile , oldNode , oldNode , useNonAdjustedPositions ) , text ) ;
281
277
}
282
278
283
- public replaceNodeRangeWithNodes ( sourceFile : SourceFile , startNode : Node , endNode : Node , newNodes : ReadonlyArray < Node > , options : ReplaceWithMultipleNodesOptions & ConfigurableStartEnd = useNonAdjustedPositions ) {
284
- return this . replaceRangeWithNodes ( sourceFile , getAdjustedRange ( sourceFile , startNode , endNode , options ) , newNodes , options ) ;
279
+ public replaceNodeRangeWithNodes ( sourceFile : SourceFile , startNode : Node , endNode : Node , newNodes : ReadonlyArray < Node > , options : ReplaceWithMultipleNodesOptions & ConfigurableStartEnd = useNonAdjustedPositions ) : void {
280
+ this . replaceRangeWithNodes ( sourceFile , getAdjustedRange ( sourceFile , startNode , endNode , options ) , newNodes , options ) ;
285
281
}
286
282
287
283
private nextCommaToken ( sourceFile : SourceFile , node : Node ) : Node | undefined {
288
284
const next = findNextToken ( node , node . parent , sourceFile ) ;
289
285
return next && next . kind === SyntaxKind . CommaToken ? next : undefined ;
290
286
}
291
287
292
- public replacePropertyAssignment ( sourceFile : SourceFile , oldNode : PropertyAssignment , newNode : PropertyAssignment ) {
288
+ public replacePropertyAssignment ( sourceFile : SourceFile , oldNode : PropertyAssignment , newNode : PropertyAssignment ) : void {
293
289
const suffix = this . nextCommaToken ( sourceFile , oldNode ) ? "" : ( "," + this . newLineCharacter ) ;
294
- return this . replaceNode ( sourceFile , oldNode , newNode , { suffix } ) ;
290
+ this . replaceNode ( sourceFile , oldNode , newNode , { suffix } ) ;
295
291
}
296
292
297
- public insertNodeAt ( sourceFile : SourceFile , pos : number , newNode : Node , options : InsertNodeOptions = { } ) {
293
+ public insertNodeAt ( sourceFile : SourceFile , pos : number , newNode : Node , options : InsertNodeOptions = { } ) : void {
298
294
this . replaceRange ( sourceFile , createRange ( pos ) , newNode , options ) ;
299
295
}
300
296
@@ -310,7 +306,7 @@ namespace ts.textChanges {
310
306
} ) ;
311
307
}
312
308
313
- public insertNodeBefore ( sourceFile : SourceFile , before : Node , newNode : Node , blankLineBetween = false ) {
309
+ public insertNodeBefore ( sourceFile : SourceFile , before : Node , newNode : Node , blankLineBetween = false ) : void {
314
310
this . insertNodeAt ( sourceFile , getAdjustedStartPosition ( sourceFile , before , { } , Position . Start ) , newNode , this . getOptionsForInsertNodeBefore ( before , blankLineBetween ) ) ;
315
311
}
316
312
@@ -343,7 +339,7 @@ namespace ts.textChanges {
343
339
this . insertText ( sourceFile , token . getStart ( sourceFile ) , text ) ;
344
340
}
345
341
346
- public insertJsdocCommentBefore ( sourceFile : SourceFile , node : HasJSDoc , tag : JSDoc ) {
342
+ public insertJsdocCommentBefore ( sourceFile : SourceFile , node : HasJSDoc , tag : JSDoc ) : void {
347
343
const fnStart = node . getStart ( sourceFile ) ;
348
344
if ( node . jsDoc ) {
349
345
for ( const jsdoc of node . jsDoc ) {
@@ -358,7 +354,7 @@ namespace ts.textChanges {
358
354
this . insertNodeAt ( sourceFile , fnStart , tag , { preserveLeadingWhitespace : false , suffix : this . newLineCharacter + indent } ) ;
359
355
}
360
356
361
- public replaceRangeWithText ( sourceFile : SourceFile , range : TextRange , text : string ) {
357
+ public replaceRangeWithText ( sourceFile : SourceFile , range : TextRange , text : string ) : void {
362
358
this . changes . push ( { kind : ChangeKind . Text , sourceFile, range, text } ) ;
363
359
}
364
360
@@ -500,7 +496,7 @@ namespace ts.textChanges {
500
496
return endPosition ;
501
497
}
502
498
503
- private getInsertNodeAfterOptions ( sourceFile : SourceFile , after : Node ) {
499
+ private getInsertNodeAfterOptions ( sourceFile : SourceFile , after : Node ) : InsertNodeOptions {
504
500
const options = this . getInsertNodeAfterOptionsWorker ( after ) ;
505
501
return {
506
502
...options ,
@@ -571,14 +567,14 @@ namespace ts.textChanges {
571
567
* i.e. arguments in arguments lists, parameters in parameter lists etc.
572
568
* Note that separators are part of the node in statements and class elements.
573
569
*/
574
- public insertNodeInListAfter ( sourceFile : SourceFile , after : Node , newNode : Node , containingList = formatting . SmartIndenter . getContainingList ( after , sourceFile ) ) {
570
+ public insertNodeInListAfter ( sourceFile : SourceFile , after : Node , newNode : Node , containingList = formatting . SmartIndenter . getContainingList ( after , sourceFile ) ) : void {
575
571
if ( ! containingList ) {
576
572
Debug . fail ( "node is not a list element" ) ;
577
- return this ;
573
+ return ;
578
574
}
579
575
const index = indexOfNode ( containingList , after ) ;
580
576
if ( index < 0 ) {
581
- return this ;
577
+ return ;
582
578
}
583
579
const end = after . getEnd ( ) ;
584
580
if ( index !== containingList . length - 1 ) {
@@ -680,7 +676,6 @@ namespace ts.textChanges {
680
676
this . replaceRange ( sourceFile , createRange ( end ) , newNode , { prefix : `${ tokenToString ( separator ) } ` } ) ;
681
677
}
682
678
}
683
- return this ;
684
679
}
685
680
686
681
private finishClassesWithNodesInsertedAtStart ( ) : void {
@@ -734,7 +729,7 @@ namespace ts.textChanges {
734
729
return changes ;
735
730
}
736
731
737
- public createNewFile ( oldFile : SourceFile | undefined , fileName : string , statements : ReadonlyArray < Statement > ) {
732
+ public createNewFile ( oldFile : SourceFile | undefined , fileName : string , statements : ReadonlyArray < Statement > ) : void {
738
733
this . newFiles . push ( { oldFile, fileName, statements } ) ;
739
734
}
740
735
}
0 commit comments