@@ -1053,7 +1053,7 @@ namespace ts.refactor.extractSymbol {
10531053 changeTracker . insertNodeBefore ( context . file , nodeToInsertBefore , newVariable , /*blankLineBetween*/ true ) ;
10541054
10551055 // Consume
1056- changeTracker . replaceRange ( context . file , { pos : node . getStart ( ) , end : node . end } , localReference ) ;
1056+ changeTracker . replaceNode ( context . file , node , localReference , textChanges . useNonAdjustedPositions ) ;
10571057 }
10581058 else {
10591059 const newVariableDeclaration = createVariableDeclaration ( localNameText , variableType , initializer ) ;
@@ -1070,15 +1070,15 @@ namespace ts.refactor.extractSymbol {
10701070
10711071 // Consume
10721072 const localReference = createIdentifier ( localNameText ) ;
1073- changeTracker . replaceRange ( context . file , { pos : node . getStart ( ) , end : node . end } , localReference ) ;
1073+ changeTracker . replaceNode ( context . file , node , localReference , textChanges . useNonAdjustedPositions ) ;
10741074 }
10751075 else if ( node . parent . kind === SyntaxKind . ExpressionStatement && scope === findAncestor ( node , isScope ) ) {
10761076 // If the parent is an expression statement and the target scope is the immediately enclosing one,
10771077 // replace the statement with the declaration.
10781078 const newVariableStatement = createVariableStatement (
10791079 /*modifiers*/ undefined ,
10801080 createVariableDeclarationList ( [ newVariableDeclaration ] , NodeFlags . Const ) ) ;
1081- changeTracker . replaceRange ( context . file , { pos : node . parent . getStart ( ) , end : node . parent . end } , newVariableStatement ) ;
1081+ changeTracker . replaceNode ( context . file , node . parent , newVariableStatement , textChanges . useNonAdjustedPositions ) ;
10821082 }
10831083 else {
10841084 const newVariableStatement = createVariableStatement (
@@ -1097,11 +1097,11 @@ namespace ts.refactor.extractSymbol {
10971097 // Consume
10981098 if ( node . parent . kind === SyntaxKind . ExpressionStatement ) {
10991099 // If the parent is an expression statement, delete it.
1100- changeTracker . deleteRange ( context . file , { pos : node . parent . getStart ( ) , end : node . parent . end } ) ;
1100+ changeTracker . deleteNode ( context . file , node . parent , textChanges . useNonAdjustedPositions ) ;
11011101 }
11021102 else {
11031103 const localReference = createIdentifier ( localNameText ) ;
1104- changeTracker . replaceRange ( context . file , { pos : node . getStart ( ) , end : node . end } , localReference ) ;
1104+ changeTracker . replaceNode ( context . file , node , localReference , textChanges . useNonAdjustedPositions ) ;
11051105 }
11061106 }
11071107 }
0 commit comments