@@ -2598,7 +2598,7 @@ module ts {
25982598 }
25992599
26002600 // TODO(drosen): use contextual SemanticMeaning.
2601- function getSymbolKind ( symbol : Symbol , typeResolver : TypeChecker , location ? : Node ) : string {
2601+ function getSymbolKind ( symbol : Symbol , typeResolver : TypeChecker , location : Node ) : string {
26022602 var flags = symbol . getFlags ( ) ;
26032603
26042604 if ( flags & SymbolFlags . Class ) return ScriptElementKind . classElement ;
@@ -3097,62 +3097,6 @@ module ts {
30973097
30983098 /// Goto definition
30993099 function getDefinitionAtPosition ( filename : string , position : number ) : DefinitionInfo [ ] {
3100- function getDefinitionInfo ( node : Node , symbolKind : string , symbolName : string , containerName : string ) : DefinitionInfo {
3101- return {
3102- fileName : node . getSourceFile ( ) . filename ,
3103- textSpan : createTextSpanFromBounds ( node . getStart ( ) , node . getEnd ( ) ) ,
3104- kind : symbolKind ,
3105- name : symbolName ,
3106- containerKind : undefined ,
3107- containerName
3108- } ;
3109- }
3110-
3111- function tryAddSignature ( signatureDeclarations : Declaration [ ] , selectConstructors : boolean , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3112- var declarations : Declaration [ ] = [ ] ;
3113- var definition : Declaration ;
3114-
3115- forEach ( signatureDeclarations , d => {
3116- if ( ( selectConstructors && d . kind === SyntaxKind . Constructor ) ||
3117- ( ! selectConstructors && ( d . kind === SyntaxKind . FunctionDeclaration || d . kind === SyntaxKind . MethodDeclaration || d . kind === SyntaxKind . MethodSignature ) ) ) {
3118- declarations . push ( d ) ;
3119- if ( ( < FunctionLikeDeclaration > d ) . body ) definition = d ;
3120- }
3121- } ) ;
3122-
3123- if ( definition ) {
3124- result . push ( getDefinitionInfo ( definition , symbolKind , symbolName , containerName ) ) ;
3125- return true ;
3126- }
3127- else if ( declarations . length ) {
3128- result . push ( getDefinitionInfo ( declarations [ declarations . length - 1 ] , symbolKind , symbolName , containerName ) ) ;
3129- return true ;
3130- }
3131-
3132- return false ;
3133- }
3134-
3135- function tryAddConstructSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3136- // Applicable only if we are in a new expression, or we are on a constructor declaration
3137- // and in either case the symbol has a construct signature definition, i.e. class
3138- if ( isNewExpressionTarget ( location ) || location . kind === SyntaxKind . ConstructorKeyword ) {
3139- if ( symbol . flags & SymbolFlags . Class ) {
3140- var classDeclaration = < ClassDeclaration > symbol . getDeclarations ( ) [ 0 ] ;
3141- Debug . assert ( classDeclaration && classDeclaration . kind === SyntaxKind . ClassDeclaration ) ;
3142-
3143- return tryAddSignature ( classDeclaration . members , /*selectConstructors*/ true , symbolKind , symbolName , containerName , result ) ;
3144- }
3145- }
3146- return false ;
3147- }
3148-
3149- function tryAddCallSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3150- if ( isCallExpressionTarget ( location ) || isNewExpressionTarget ( location ) || isNameOfFunctionDeclaration ( location ) ) {
3151- return tryAddSignature ( symbol . declarations , /*selectConstructors*/ false , symbolKind , symbolName , containerName , result ) ;
3152- }
3153- return false ;
3154- }
3155-
31563100 synchronizeHostData ( ) ;
31573101
31583102 filename = normalizeSlashes ( filename ) ;
@@ -3205,7 +3149,7 @@ module ts {
32053149 if ( node . parent . kind === SyntaxKind . ShorthandPropertyAssignment ) {
32063150 var shorthandSymbol = typeInfoResolver . getShorthandAssignmentValueSymbol ( symbol . valueDeclaration ) ;
32073151 var shorthandDeclarations = shorthandSymbol . getDeclarations ( ) ;
3208- var shorthandSymbolKind = getSymbolKind ( shorthandSymbol , typeInfoResolver ) ;
3152+ var shorthandSymbolKind = getSymbolKind ( shorthandSymbol , typeInfoResolver , node ) ;
32093153 var shorthandSymbolName = typeInfoResolver . symbolToString ( shorthandSymbol ) ;
32103154 var shorthandContainerName = typeInfoResolver . symbolToString ( symbol . parent , node ) ;
32113155 forEach ( shorthandDeclarations , declaration => {
@@ -3216,7 +3160,7 @@ module ts {
32163160
32173161 var declarations = symbol . getDeclarations ( ) ;
32183162 var symbolName = typeInfoResolver . symbolToString ( symbol ) ; // Do not get scoped name, just the name of the symbol
3219- var symbolKind = getSymbolKind ( symbol , typeInfoResolver ) ;
3163+ var symbolKind = getSymbolKind ( symbol , typeInfoResolver , node ) ;
32203164 var containerSymbol = symbol . parent ;
32213165 var containerName = containerSymbol ? typeInfoResolver . symbolToString ( containerSymbol , node ) : "" ;
32223166
@@ -3229,6 +3173,62 @@ module ts {
32293173 }
32303174
32313175 return result ;
3176+
3177+ function getDefinitionInfo ( node : Node , symbolKind : string , symbolName : string , containerName : string ) : DefinitionInfo {
3178+ return {
3179+ fileName : node . getSourceFile ( ) . filename ,
3180+ textSpan : createTextSpanFromBounds ( node . getStart ( ) , node . getEnd ( ) ) ,
3181+ kind : symbolKind ,
3182+ name : symbolName ,
3183+ containerKind : undefined ,
3184+ containerName
3185+ } ;
3186+ }
3187+
3188+ function tryAddSignature ( signatureDeclarations : Declaration [ ] , selectConstructors : boolean , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3189+ var declarations : Declaration [ ] = [ ] ;
3190+ var definition : Declaration ;
3191+
3192+ forEach ( signatureDeclarations , d => {
3193+ if ( ( selectConstructors && d . kind === SyntaxKind . Constructor ) ||
3194+ ( ! selectConstructors && ( d . kind === SyntaxKind . FunctionDeclaration || d . kind === SyntaxKind . MethodDeclaration || d . kind === SyntaxKind . MethodSignature ) ) ) {
3195+ declarations . push ( d ) ;
3196+ if ( ( < FunctionLikeDeclaration > d ) . body ) definition = d ;
3197+ }
3198+ } ) ;
3199+
3200+ if ( definition ) {
3201+ result . push ( getDefinitionInfo ( definition , symbolKind , symbolName , containerName ) ) ;
3202+ return true ;
3203+ }
3204+ else if ( declarations . length ) {
3205+ result . push ( getDefinitionInfo ( declarations [ declarations . length - 1 ] , symbolKind , symbolName , containerName ) ) ;
3206+ return true ;
3207+ }
3208+
3209+ return false ;
3210+ }
3211+
3212+ function tryAddConstructSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3213+ // Applicable only if we are in a new expression, or we are on a constructor declaration
3214+ // and in either case the symbol has a construct signature definition, i.e. class
3215+ if ( isNewExpressionTarget ( location ) || location . kind === SyntaxKind . ConstructorKeyword ) {
3216+ if ( symbol . flags & SymbolFlags . Class ) {
3217+ var classDeclaration = < ClassDeclaration > symbol . getDeclarations ( ) [ 0 ] ;
3218+ Debug . assert ( classDeclaration && classDeclaration . kind === SyntaxKind . ClassDeclaration ) ;
3219+
3220+ return tryAddSignature ( classDeclaration . members , /*selectConstructors*/ true , symbolKind , symbolName , containerName , result ) ;
3221+ }
3222+ }
3223+ return false ;
3224+ }
3225+
3226+ function tryAddCallSignature ( symbol : Symbol , location : Node , symbolKind : string , symbolName : string , containerName : string , result : DefinitionInfo [ ] ) {
3227+ if ( isCallExpressionTarget ( location ) || isNewExpressionTarget ( location ) || isNameOfFunctionDeclaration ( location ) ) {
3228+ return tryAddSignature ( symbol . declarations , /*selectConstructors*/ false , symbolKind , symbolName , containerName , result ) ;
3229+ }
3230+ return false ;
3231+ }
32323232 }
32333233
32343234 /// References and Occurrences
@@ -5273,7 +5273,7 @@ module ts {
52735273
52745274 // Only allow a symbol to be renamed if it actually has at least one declaration.
52755275 if ( symbol && symbol . getDeclarations ( ) && symbol . getDeclarations ( ) . length > 0 ) {
5276- var kind = getSymbolKind ( symbol , typeInfoResolver ) ;
5276+ var kind = getSymbolKind ( symbol , typeInfoResolver , node ) ;
52775277 if ( kind ) {
52785278 return getRenameInfo ( symbol . name , typeInfoResolver . getFullyQualifiedName ( symbol ) , kind ,
52795279 getSymbolModifiers ( symbol ) ,
0 commit comments