@@ -32,6 +32,13 @@ namespace ts.GoToDefinition {
32
32
return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
33
33
}
34
34
35
+ if ( [ SyntaxKind . CaseKeyword , SyntaxKind . DefaultKeyword ] . indexOf ( node . kind ) !== - 1 ) {
36
+ const switchStatement = findAncestor ( node . parent , n => n . kind === SyntaxKind . SwitchStatement ) as SwitchStatement | undefined ;
37
+ if ( switchStatement ) {
38
+ return [ createDefinitionInfoFromSwitchStatement ( switchStatement ) ] ;
39
+ }
40
+ }
41
+
35
42
if ( isStaticModifier ( node ) && isClassStaticBlockDeclaration ( node . parent ) ) {
36
43
const classDecl = node . parent . parent ;
37
44
const { symbol, failedAliasResolution } = getSymbol ( classDecl , typeChecker , stopAtAlias ) ;
@@ -510,4 +517,22 @@ namespace ts.GoToDefinition {
510
517
return false ;
511
518
}
512
519
}
520
+
521
+ function createDefinitionInfoFromSwitchStatement ( statement : SwitchStatement ) : DefinitionInfo {
522
+ const switchKeyword = find ( statement . getChildren ( ) , n => n . kind === SyntaxKind . SwitchKeyword ) ;
523
+ const sourceFile = statement . getSourceFile ( ) ;
524
+ return {
525
+ fileName : sourceFile . fileName ,
526
+ textSpan : createTextSpanFromNode ( switchKeyword ! ) ,
527
+ kind : ScriptElementKind . label ,
528
+ name : "switch" ,
529
+ containerKind : ScriptElementKind . unknown ,
530
+ containerName : "" ,
531
+ contextSpan : createTextSpanFromNode ( statement ) ,
532
+ isLocal : false ,
533
+ isAmbient : false ,
534
+ unverified : false ,
535
+ failedAliasResolution : undefined ,
536
+ } ;
537
+ }
513
538
}
0 commit comments