File tree Expand file tree Collapse file tree 2 files changed +35
-35
lines changed Expand file tree Collapse file tree 2 files changed +35
-35
lines changed Original file line number Diff line number Diff line change @@ -3469,41 +3469,6 @@ module ts {
3469
3469
return getAncestor ( node , kind ) !== undefined ;
3470
3470
}
3471
3471
3472
- function getAncestor ( node : Node , kind : SyntaxKind ) : Node {
3473
- switch ( kind ) {
3474
- // special-cases that can be come first
3475
- case SyntaxKind . ClassDeclaration :
3476
- while ( node ) {
3477
- switch ( node . kind ) {
3478
- case SyntaxKind . ClassDeclaration :
3479
- return < ClassDeclaration > node ;
3480
- case SyntaxKind . EnumDeclaration :
3481
- case SyntaxKind . InterfaceDeclaration :
3482
- case SyntaxKind . ModuleDeclaration :
3483
- case SyntaxKind . ImportDeclaration :
3484
- // early exit cases - declarations cannot be nested in classes
3485
- return undefined ;
3486
- default :
3487
- node = node . parent ;
3488
- continue ;
3489
- }
3490
- }
3491
- break ;
3492
- default :
3493
- while ( node ) {
3494
- if ( node . kind === kind ) {
3495
- return node ;
3496
- }
3497
- else {
3498
- node = node . parent ;
3499
- }
3500
- }
3501
- break ;
3502
- }
3503
-
3504
- return undefined ;
3505
- }
3506
-
3507
3472
// EXPRESSION TYPE CHECKING
3508
3473
3509
3474
function checkIdentifier ( node : Identifier ) : Type {
Original file line number Diff line number Diff line change @@ -505,6 +505,41 @@ module ts {
505
505
return false ;
506
506
}
507
507
508
+ export function getAncestor ( node : Node , kind : SyntaxKind ) : Node {
509
+ switch ( kind ) {
510
+ // special-cases that can be come first
511
+ case SyntaxKind . ClassDeclaration :
512
+ while ( node ) {
513
+ switch ( node . kind ) {
514
+ case SyntaxKind . ClassDeclaration :
515
+ return < ClassDeclaration > node ;
516
+ case SyntaxKind . EnumDeclaration :
517
+ case SyntaxKind . InterfaceDeclaration :
518
+ case SyntaxKind . ModuleDeclaration :
519
+ case SyntaxKind . ImportDeclaration :
520
+ // early exit cases - declarations cannot be nested in classes
521
+ return undefined ;
522
+ default :
523
+ node = node . parent ;
524
+ continue ;
525
+ }
526
+ }
527
+ break ;
528
+ default :
529
+ while ( node ) {
530
+ if ( node . kind === kind ) {
531
+ return node ;
532
+ }
533
+ else {
534
+ node = node . parent ;
535
+ }
536
+ }
537
+ break ;
538
+ }
539
+
540
+ return undefined ;
541
+ }
542
+
508
543
enum ParsingContext {
509
544
SourceElements , // Elements in source file
510
545
ModuleElements , // Elements in module declaration
You can’t perform that action at this time.
0 commit comments