@@ -26,10 +26,22 @@ namespace ts.GoToDefinition {
26
26
return label ? [ createDefinitionInfoFromName ( typeChecker , label , ScriptElementKind . label , node . text , /*containerName*/ undefined ! ) ] : undefined ; // TODO: GH#18217
27
27
}
28
28
29
- if ( node . kind === SyntaxKind . ReturnKeyword ) {
30
- const functionDeclaration = findAncestor ( node . parent , n =>
31
- isClassStaticBlockDeclaration ( n ) ? "quit" : isFunctionLikeDeclaration ( n ) ) as FunctionLikeDeclaration | undefined ;
32
- return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
29
+ switch ( node . kind ) {
30
+ case SyntaxKind . ReturnKeyword :
31
+ const functionDeclaration = findAncestor ( node . parent , n =>
32
+ isClassStaticBlockDeclaration ( n ) ? "quit" : isFunctionLikeDeclaration ( n ) ) as FunctionLikeDeclaration | undefined ;
33
+ return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
34
+ case SyntaxKind . DefaultKeyword :
35
+ if ( ! isDefaultClause ( node . parent ) ) {
36
+ break ;
37
+ }
38
+ // falls through
39
+ case SyntaxKind . CaseKeyword :
40
+ const switchStatement = findAncestor ( node . parent , isSwitchStatement ) ;
41
+ if ( switchStatement ) {
42
+ return [ createDefinitionInfoFromNode ( switchStatement , "switch" ) ] ;
43
+ }
44
+ break ;
33
45
}
34
46
35
47
if ( isStaticModifier ( node ) && isClassStaticBlockDeclaration ( node . parent ) ) {
@@ -510,4 +522,21 @@ namespace ts.GoToDefinition {
510
522
return false ;
511
523
}
512
524
}
525
+
526
+ function createDefinitionInfoFromNode ( node : Node , name : string ) : DefinitionInfo {
527
+ const sourceFile = node . getSourceFile ( ) ;
528
+ return {
529
+ fileName : sourceFile . fileName ,
530
+ textSpan : createTextSpanFromNode ( node , sourceFile ) ,
531
+ kind : ScriptElementKind . label ,
532
+ name,
533
+ containerKind : ScriptElementKind . unknown ,
534
+ containerName : "" ,
535
+ contextSpan : createTextSpanFromNode ( node , sourceFile ) ,
536
+ isLocal : false ,
537
+ isAmbient : false ,
538
+ unverified : false ,
539
+ failedAliasResolution : undefined ,
540
+ } ;
541
+ }
513
542
}
0 commit comments