@@ -2585,7 +2585,7 @@ module ts {
25852585 }
25862586
25872587 // TODO(drosen): use contextual SemanticMeaning.
2588- function getSymbolKind ( symbol : Symbol , typeResolver : TypeChecker , location ? : Node ) : string {
2588+ function getSymbolKind ( symbol : Symbol , typeResolver : TypeChecker , location : Node ) : string {
25892589 var flags = symbol . getFlags ( ) ;
25902590
25912591 if ( flags & SymbolFlags . Class ) return ScriptElementKind . classElement ;
@@ -3084,62 +3084,6 @@ module ts {
30843084
30853085 /// Goto definition
30863086 function getDefinitionAtPosition ( filename : string , position : number ) : DefinitionInfo [ ] {
3087- function getDefinitionInfo ( node : Node , symbolKind : string , symbolName : string , containerName : string ) : DefinitionInfo {
3088- return {
3089- fileName : node . getSourceFile ( ) . filename ,
3090- textSpan : createTextSpanFromBounds ( node . getStart ( ) , node . getEnd ( ) ) ,
3091- kind : symbolKind ,
3092- name : symbolName ,
3093- containerKind : undefined ,
3094- containerName
3095- } ;
3096- }
3097-
3098- function tryAddSignature ( signatureDeclarations : Declaration [ ] , selectConstructors : boolean , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3099- var declarations : Declaration [ ] = [ ] ;
3100- var definition : Declaration ;
3101-
3102- forEach ( signatureDeclarations , d => {
3103- if ( ( selectConstructors && d . kind === SyntaxKind . Constructor ) ||
3104- ( ! selectConstructors && ( d . kind === SyntaxKind . FunctionDeclaration || d . kind === SyntaxKind . MethodDeclaration || d . kind === SyntaxKind . MethodSignature ) ) ) {
3105- declarations . push ( d ) ;
3106- if ( ( < FunctionLikeDeclaration > d ) . body ) definition = d ;
3107- }
3108- } ) ;
3109-
3110- if ( definition ) {
3111- result . push ( getDefinitionInfo ( definition , symbolKind , symbolName , containerName ) ) ;
3112- return true ;
3113- }
3114- else if ( declarations . length ) {
3115- result . push ( getDefinitionInfo ( declarations [ declarations . length - 1 ] , symbolKind , symbolName , containerName ) ) ;
3116- return true ;
3117- }
3118-
3119- return false ;
3120- }
3121-
3122- function tryAddConstructSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3123- // Applicable only if we are in a new expression, or we are on a constructor declaration
3124- // and in either case the symbol has a construct signature definition, i.e. class
3125- if ( isNewExpressionTarget ( location ) || location . kind === SyntaxKind . ConstructorKeyword ) {
3126- if ( symbol . flags & SymbolFlags . Class ) {
3127- var classDeclaration = < ClassDeclaration > symbol . getDeclarations ( ) [ 0 ] ;
3128- Debug . assert ( classDeclaration && classDeclaration . kind === SyntaxKind . ClassDeclaration ) ;
3129-
3130- return tryAddSignature ( classDeclaration . members , /*selectConstructors*/ true , symbolKind , symbolName , containerName , result ) ;
3131- }
3132- }
3133- return false ;
3134- }
3135-
3136- function tryAddCallSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3137- if ( isCallExpressionTarget ( location ) || isNewExpressionTarget ( location ) || isNameOfFunctionDeclaration ( location ) ) {
3138- return tryAddSignature ( symbol . declarations , /*selectConstructors*/ false , symbolKind , symbolName , containerName , result ) ;
3139- }
3140- return false ;
3141- }
3142-
31433087 synchronizeHostData ( ) ;
31443088
31453089 filename = normalizeSlashes ( filename ) ;
@@ -3192,7 +3136,7 @@ module ts {
31923136 if ( node . parent . kind === SyntaxKind . ShorthandPropertyAssignment ) {
31933137 var shorthandSymbol = typeInfoResolver . getShorthandAssignmentValueSymbol ( symbol . valueDeclaration ) ;
31943138 var shorthandDeclarations = shorthandSymbol . getDeclarations ( ) ;
3195- var shorthandSymbolKind = getSymbolKind ( shorthandSymbol , typeInfoResolver ) ;
3139+ var shorthandSymbolKind = getSymbolKind ( shorthandSymbol , typeInfoResolver , node ) ;
31963140 var shorthandSymbolName = typeInfoResolver . symbolToString ( shorthandSymbol ) ;
31973141 var shorthandContainerName = typeInfoResolver . symbolToString ( symbol . parent , node ) ;
31983142 forEach ( shorthandDeclarations , declaration => {
@@ -3203,7 +3147,7 @@ module ts {
32033147
32043148 var declarations = symbol . getDeclarations ( ) ;
32053149 var symbolName = typeInfoResolver . symbolToString ( symbol ) ; // Do not get scoped name, just the name of the symbol
3206- var symbolKind = getSymbolKind ( symbol , typeInfoResolver ) ;
3150+ var symbolKind = getSymbolKind ( symbol , typeInfoResolver , node ) ;
32073151 var containerSymbol = symbol . parent ;
32083152 var containerName = containerSymbol ? typeInfoResolver . symbolToString ( containerSymbol , node ) : "" ;
32093153
@@ -3216,6 +3160,62 @@ module ts {
32163160 }
32173161
32183162 return result ;
3163+
3164+ function getDefinitionInfo ( node : Node , symbolKind : string , symbolName : string , containerName : string ) : DefinitionInfo {
3165+ return {
3166+ fileName : node . getSourceFile ( ) . filename ,
3167+ textSpan : createTextSpanFromBounds ( node . getStart ( ) , node . getEnd ( ) ) ,
3168+ kind : symbolKind ,
3169+ name : symbolName ,
3170+ containerKind : undefined ,
3171+ containerName
3172+ } ;
3173+ }
3174+
3175+ function tryAddSignature ( signatureDeclarations : Declaration [ ] , selectConstructors : boolean , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3176+ var declarations : Declaration [ ] = [ ] ;
3177+ var definition : Declaration ;
3178+
3179+ forEach ( signatureDeclarations , d => {
3180+ if ( ( selectConstructors && d . kind === SyntaxKind . Constructor ) ||
3181+ ( ! selectConstructors && ( d . kind === SyntaxKind . FunctionDeclaration || d . kind === SyntaxKind . MethodDeclaration || d . kind === SyntaxKind . MethodSignature ) ) ) {
3182+ declarations . push ( d ) ;
3183+ if ( ( < FunctionLikeDeclaration > d ) . body ) definition = d ;
3184+ }
3185+ } ) ;
3186+
3187+ if ( definition ) {
3188+ result . push ( getDefinitionInfo ( definition , symbolKind , symbolName , containerName ) ) ;
3189+ return true ;
3190+ }
3191+ else if ( declarations . length ) {
3192+ result . push ( getDefinitionInfo ( declarations [ declarations . length - 1 ] , symbolKind , symbolName , containerName ) ) ;
3193+ return true ;
3194+ }
3195+
3196+ return false ;
3197+ }
3198+
3199+ function tryAddConstructSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3200+ // Applicable only if we are in a new expression, or we are on a constructor declaration
3201+ // and in either case the symbol has a construct signature definition, i.e. class
3202+ if ( isNewExpressionTarget ( location ) || location . kind === SyntaxKind . ConstructorKeyword ) {
3203+ if ( symbol . flags & SymbolFlags . Class ) {
3204+ var classDeclaration = < ClassDeclaration > symbol . getDeclarations ( ) [ 0 ] ;
3205+ Debug . assert ( classDeclaration && classDeclaration . kind === SyntaxKind . ClassDeclaration ) ;
3206+
3207+ return tryAddSignature ( classDeclaration . members , /*selectConstructors*/ true , symbolKind , symbolName , containerName , result ) ;
3208+ }
3209+ }
3210+ return false ;
3211+ }
3212+
3213+ function tryAddCallSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3214+ if ( isCallExpressionTarget ( location ) || isNewExpressionTarget ( location ) || isNameOfFunctionDeclaration ( location ) ) {
3215+ return tryAddSignature ( symbol . declarations , /*selectConstructors*/ false , symbolKind , symbolName , containerName , result ) ;
3216+ }
3217+ return false ;
3218+ }
32193219 }
32203220
32213221 /// References and Occurrences
@@ -5259,7 +5259,7 @@ module ts {
52595259
52605260 // Only allow a symbol to be renamed if it actually has at least one declaration.
52615261 if ( symbol && symbol . getDeclarations ( ) && symbol . getDeclarations ( ) . length > 0 ) {
5262- var kind = getSymbolKind ( symbol , typeInfoResolver ) ;
5262+ var kind = getSymbolKind ( symbol , typeInfoResolver , node ) ;
52635263 if ( kind ) {
52645264 return getRenameInfo ( symbol . name , typeInfoResolver . getFullyQualifiedName ( symbol ) , kind ,
52655265 getSymbolModifiers ( symbol ) ,
0 commit comments