@@ -1088,7 +1088,7 @@ namespace ts.refactor.extractSymbol {
1088
1088
}
1089
1089
}
1090
1090
1091
- function transformFunctionBody ( body : Node , writes : ReadonlyArray < UsageEntry > , substitutions : ReadonlyMap < ( ) => Node > , hasReturn : boolean ) : { body : Block , returnValueProperty : string } {
1091
+ function transformFunctionBody ( body : Node , writes : ReadonlyArray < UsageEntry > , substitutions : ReadonlyMap < Node > , hasReturn : boolean ) : { body : Block , returnValueProperty : string } {
1092
1092
if ( isBlock ( body ) && ! writes && substitutions . size === 0 ) {
1093
1093
// already block, no writes to propagate back, no substitutions - can use node as is
1094
1094
return { body : createBlock ( body . statements , /*multLine*/ true ) , returnValueProperty : undefined } ;
@@ -1136,21 +1136,21 @@ namespace ts.refactor.extractSymbol {
1136
1136
const oldIgnoreReturns = ignoreReturns ;
1137
1137
ignoreReturns = ignoreReturns || isFunctionLikeDeclaration ( node ) || isClassLike ( node ) ;
1138
1138
const substitution = substitutions . get ( getNodeId ( node ) . toString ( ) ) ;
1139
- const result = substitution ? substitution ( ) : visitEachChild ( node , visitor , nullTransformationContext ) ;
1139
+ const result = substitution ? getSynthesizedDeepClone ( substitution ) : visitEachChild ( node , visitor , nullTransformationContext ) ;
1140
1140
ignoreReturns = oldIgnoreReturns ;
1141
1141
return result ;
1142
1142
}
1143
1143
}
1144
1144
}
1145
1145
1146
- function transformConstantInitializer ( initializer : Expression , substitutions : ReadonlyMap < ( ) => Node > ) : Expression {
1146
+ function transformConstantInitializer ( initializer : Expression , substitutions : ReadonlyMap < Node > ) : Expression {
1147
1147
return substitutions . size
1148
1148
? visitor ( initializer ) as Expression
1149
1149
: initializer ;
1150
1150
1151
1151
function visitor ( node : Node ) : VisitResult < Node > {
1152
1152
const substitution = substitutions . get ( getNodeId ( node ) . toString ( ) ) ;
1153
- return substitution ? substitution ( ) : visitEachChild ( node , visitor , nullTransformationContext ) ;
1153
+ return substitution ? getSynthesizedDeepClone ( substitution ) : visitEachChild ( node , visitor , nullTransformationContext ) ;
1154
1154
}
1155
1155
}
1156
1156
@@ -1279,7 +1279,7 @@ namespace ts.refactor.extractSymbol {
1279
1279
interface ScopeUsages {
1280
1280
readonly usages : Map < UsageEntry > ;
1281
1281
readonly typeParameterUsages : Map < TypeParameter > ; // Key is type ID
1282
- readonly substitutions : Map < ( ) => Node > ;
1282
+ readonly substitutions : Map < Node > ;
1283
1283
}
1284
1284
1285
1285
interface ReadsAndWrites {
@@ -1298,7 +1298,7 @@ namespace ts.refactor.extractSymbol {
1298
1298
1299
1299
const allTypeParameterUsages = createMap < TypeParameter > ( ) ; // Key is type ID
1300
1300
const usagesPerScope : ScopeUsages [ ] = [ ] ;
1301
- const substitutionsPerScope : Map < ( ) => Node > [ ] = [ ] ;
1301
+ const substitutionsPerScope : Map < Node > [ ] = [ ] ;
1302
1302
const functionErrorsPerScope : Diagnostic [ ] [ ] = [ ] ;
1303
1303
const constantErrorsPerScope : Diagnostic [ ] [ ] = [ ] ;
1304
1304
const visibleDeclarationsInExtractedRange : Symbol [ ] = [ ] ;
@@ -1322,8 +1322,8 @@ namespace ts.refactor.extractSymbol {
1322
1322
1323
1323
// initialize results
1324
1324
for ( const scope of scopes ) {
1325
- usagesPerScope . push ( { usages : createMap < UsageEntry > ( ) , typeParameterUsages : createMap < TypeParameter > ( ) , substitutions : createMap < ( ) => Expression > ( ) } ) ;
1326
- substitutionsPerScope . push ( createMap < ( ) => Expression > ( ) ) ;
1325
+ usagesPerScope . push ( { usages : createMap < UsageEntry > ( ) , typeParameterUsages : createMap < TypeParameter > ( ) , substitutions : createMap < Expression > ( ) } ) ;
1326
+ substitutionsPerScope . push ( createMap < Expression > ( ) ) ;
1327
1327
1328
1328
functionErrorsPerScope . push (
1329
1329
isFunctionLikeDeclaration ( scope ) && scope . kind !== SyntaxKind . FunctionDeclaration
@@ -1622,20 +1622,20 @@ namespace ts.refactor.extractSymbol {
1622
1622
}
1623
1623
}
1624
1624
1625
- function tryReplaceWithQualifiedNameOrPropertyAccess ( symbol : Symbol , scopeDecl : Node , isTypeNode : boolean ) : ( ) => ( PropertyAccessExpression | EntityName ) {
1625
+ function tryReplaceWithQualifiedNameOrPropertyAccess ( symbol : Symbol , scopeDecl : Node , isTypeNode : boolean ) : PropertyAccessExpression | EntityName {
1626
1626
if ( ! symbol ) {
1627
1627
return undefined ;
1628
1628
}
1629
1629
if ( symbol . getDeclarations ( ) . some ( d => d . parent === scopeDecl ) ) {
1630
- return ( ) => createIdentifier ( symbol . name ) ;
1630
+ return createIdentifier ( symbol . name ) ;
1631
1631
}
1632
1632
const prefix = tryReplaceWithQualifiedNameOrPropertyAccess ( symbol . parent , scopeDecl , isTypeNode ) ;
1633
1633
if ( prefix === undefined ) {
1634
1634
return undefined ;
1635
1635
}
1636
1636
return isTypeNode
1637
- ? ( ) => createQualifiedName ( < EntityName > prefix ( ) , createIdentifier ( symbol . name ) )
1638
- : ( ) => createPropertyAccess ( < Expression > prefix ( ) , symbol . name ) ;
1637
+ ? createQualifiedName ( < EntityName > prefix , createIdentifier ( symbol . name ) )
1638
+ : createPropertyAccess ( < Expression > prefix , symbol . name ) ;
1639
1639
}
1640
1640
}
1641
1641
0 commit comments