@@ -222,7 +222,8 @@ module ts.formatting {
222
222
if ( node . parent ) {
223
223
switch ( node . parent . kind ) {
224
224
case SyntaxKind . TypeReference :
225
- if ( ( < TypeReferenceNode > node . parent ) . typeArguments ) {
225
+ if ( ( < TypeReferenceNode > node . parent ) . typeArguments &&
226
+ rangeContainsStartEnd ( ( < TypeReferenceNode > node . parent ) . typeArguments , node . getStart ( sourceFile ) , node . getEnd ( ) ) ) {
226
227
return ( < TypeReferenceNode > node . parent ) . typeArguments ;
227
228
}
228
229
break ;
@@ -236,21 +237,28 @@ module ts.formatting {
236
237
case SyntaxKind . Method :
237
238
case SyntaxKind . CallSignature :
238
239
case SyntaxKind . ConstructSignature :
239
- if ( ( < SignatureDeclaration > node . parent ) .typeParameters && node . end < ( < SignatureDeclaration > node . parent ) . typeParameters . end ) {
240
+ var start = node . getStart ( sourceFile ) ;
241
+ if ( ( < SignatureDeclaration > node . parent ) . typeParameters &&
242
+ rangeContainsStartEnd ( ( < SignatureDeclaration > node . parent ) . typeParameters , start , node . getEnd ( ) ) ) {
240
243
return ( < SignatureDeclaration > node . parent ) . typeParameters ;
241
244
}
242
-
243
- return ( < SignatureDeclaration > node . parent ) . parameters ;
245
+ if ( rangeContainsStartEnd ( ( < SignatureDeclaration > node . parent ) . parameters , start , node . getEnd ( ) ) ) {
246
+ return ( < SignatureDeclaration > node . parent ) . parameters ;
247
+ }
248
+ break ;
244
249
case SyntaxKind . NewExpression :
245
250
case SyntaxKind . CallExpression :
246
- if ( ( < CallExpression > node . parent ) . typeArguments && node . end < ( < CallExpression > node . parent ) . typeArguments . end ) {
251
+ var start = node . getStart ( sourceFile ) ;
252
+ if ( ( < CallExpression > node . parent ) . typeArguments &&
253
+ rangeContainsStartEnd ( ( < CallExpression > node . parent ) . typeArguments , start , node . getEnd ( ) ) ) {
247
254
return ( < CallExpression > node . parent ) . typeArguments ;
248
255
}
249
-
250
- return ( < CallExpression > node . parent ) . arguments ;
256
+ if ( rangeContainsStartEnd ( ( < CallExpression > node . parent ) . arguments , start , node . getEnd ( ) ) ) {
257
+ return ( < CallExpression > node . parent ) . arguments ;
258
+ }
259
+ break ;
251
260
}
252
261
}
253
-
254
262
return undefined ;
255
263
}
256
264
0 commit comments