File tree Expand file tree Collapse file tree 3 files changed +27
-30
lines changed Expand file tree Collapse file tree 3 files changed +27
-30
lines changed Original file line number Diff line number Diff line change @@ -7113,15 +7113,4 @@ module ts {
7113
7113
7114
7114
return checker ;
7115
7115
}
7116
-
7117
- export function getContainingFunction ( node : Node ) : SignatureDeclaration {
7118
- while ( true ) {
7119
- node = node . parent ;
7120
- if ( ! node || node . kind === SyntaxKind . FunctionDeclaration || node . kind === SyntaxKind . FunctionExpression ||
7121
- node . kind === SyntaxKind . ArrowFunction || node . kind === SyntaxKind . Method || node . kind === SyntaxKind . Constructor ||
7122
- node . kind === SyntaxKind . GetAccessor || node . kind === SyntaxKind . SetAccessor ) {
7123
- return < SignatureDeclaration > node ;
7124
- }
7125
- }
7126
- }
7127
7116
}
Original file line number Diff line number Diff line change @@ -380,6 +380,32 @@ module ts {
380
380
}
381
381
}
382
382
383
+ export function isAnyFunction ( node : Node ) : boolean {
384
+ if ( node ) {
385
+ switch ( node . kind ) {
386
+ case SyntaxKind . FunctionExpression :
387
+ case SyntaxKind . FunctionDeclaration :
388
+ case SyntaxKind . ArrowFunction :
389
+ case SyntaxKind . Method :
390
+ case SyntaxKind . GetAccessor :
391
+ case SyntaxKind . SetAccessor :
392
+ case SyntaxKind . Constructor :
393
+ return true ;
394
+ }
395
+ }
396
+
397
+ return false ;
398
+ }
399
+
400
+ export function getContainingFunction ( node : Node ) : SignatureDeclaration {
401
+ while ( true ) {
402
+ node = node . parent ;
403
+ if ( ! node || isAnyFunction ( node ) ) {
404
+ return < SignatureDeclaration > node ;
405
+ }
406
+ }
407
+ }
408
+
383
409
export function hasRestParameters ( s : SignatureDeclaration ) : boolean {
384
410
return s . parameters . length > 0 && ( s . parameters [ s . parameters . length - 1 ] . flags & NodeFlags . Rest ) !== 0 ;
385
411
}
Original file line number Diff line number Diff line change @@ -1312,24 +1312,6 @@ module ts {
1312
1312
return node . parent . kind === SyntaxKind . NewExpression && ( < CallExpression > node . parent ) . func === node ;
1313
1313
}
1314
1314
1315
- function isAnyFunction ( node : Node ) : boolean {
1316
- if ( ! node ) {
1317
- return false ;
1318
- }
1319
-
1320
- switch ( node . kind ) {
1321
- case SyntaxKind . FunctionExpression :
1322
- case SyntaxKind . FunctionDeclaration :
1323
- case SyntaxKind . ArrowFunction :
1324
- case SyntaxKind . Method :
1325
- case SyntaxKind . GetAccessor :
1326
- case SyntaxKind . SetAccessor :
1327
- case SyntaxKind . Constructor :
1328
- return true ;
1329
- }
1330
- return false ;
1331
- }
1332
-
1333
1315
function isNameOfFunctionDeclaration ( node : Node ) : boolean {
1334
1316
return node . kind === SyntaxKind . Identifier &&
1335
1317
isAnyFunction ( node . parent ) && ( < FunctionDeclaration > node . parent ) . name === node ;
@@ -2274,7 +2256,7 @@ module ts {
2274
2256
var func = < FunctionDeclaration > getContainingFunction ( returnStatement ) ;
2275
2257
2276
2258
// If we didn't find a containing function with a block body, bail out.
2277
- if ( ! ( isAnyFunction ( func ) && hasKind ( func . body , SyntaxKind . FunctionBlock ) ) ) {
2259
+ if ( ! ( func && hasKind ( func . body , SyntaxKind . FunctionBlock ) ) ) {
2278
2260
return undefined ;
2279
2261
}
2280
2262
You can’t perform that action at this time.
0 commit comments