@@ -32,6 +32,13 @@ namespace ts.GoToDefinition {
3232 return functionDeclaration ? [ createDefinitionFromSignatureDeclaration ( typeChecker , functionDeclaration ) ] : undefined ;
3333 }
3434
35+ if ( node . kind === SyntaxKind . CaseKeyword || node . kind === SyntaxKind . DefaultKeyword ) {
36+ const switchStatement = findAncestor ( node . parent , isSwitchStatement ) ;
37+ if ( switchStatement ) {
38+ return [ createDefinitionInfoFromNode ( switchStatement , "switch" ) ] ;
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,21 @@ namespace ts.GoToDefinition {
510517 return false ;
511518 }
512519 }
520+
521+ function createDefinitionInfoFromNode ( node : Node , name : string ) : DefinitionInfo {
522+ const sourceFile = node . getSourceFile ( ) ;
523+ return {
524+ fileName : sourceFile . fileName ,
525+ textSpan : createTextSpanFromNode ( node , sourceFile ) ,
526+ kind : ScriptElementKind . label ,
527+ name,
528+ containerKind : ScriptElementKind . unknown ,
529+ containerName : "" ,
530+ contextSpan : createTextSpanFromNode ( node , sourceFile ) ,
531+ isLocal : false ,
532+ isAmbient : false ,
533+ unverified : false ,
534+ failedAliasResolution : undefined ,
535+ } ;
536+ }
513537}
0 commit comments