@@ -32,6 +32,13 @@ namespace ts.GoToDefinition {
3232 return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
3333 }
3434
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+
3542 if ( isStaticModifier ( node ) && isClassStaticBlockDeclaration ( node . parent ) ) {
3643 const classDecl = node . parent . parent ;
3744 const { symbol, failedAliasResolution } = getSymbol ( classDecl , typeChecker , stopAtAlias ) ;
@@ -510,4 +517,22 @@ namespace ts.GoToDefinition {
510517 return false ;
511518 }
512519 }
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+ }
513538}
0 commit comments