@@ -2250,7 +2250,7 @@ module ts {
2250
2250
return undefined ;
2251
2251
}
2252
2252
2253
- function createCompletionEntry ( symbol : Symbol ) : CompletionEntry {
2253
+ function createCompletionEntry ( symbol : Symbol , typeChecker : TypeChecker ) : CompletionEntry {
2254
2254
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
2255
2255
// We would like to only show things that can be added after a dot, so for instance numeric properties can
2256
2256
// not be accessed with a dot (a.1 <- invalid)
@@ -2261,15 +2261,15 @@ module ts {
2261
2261
2262
2262
return {
2263
2263
name : displayName ,
2264
- kind : getSymbolKind ( symbol ) ,
2264
+ kind : getSymbolKind ( symbol , typeChecker ) ,
2265
2265
kindModifiers : getSymbolModifiers ( symbol )
2266
2266
} ;
2267
2267
}
2268
2268
2269
2269
function getCompletionsAtPosition ( filename : string , position : number , isMemberCompletion : boolean ) {
2270
2270
function getCompletionEntriesFromSymbols ( symbols : Symbol [ ] , session : CompletionSession ) : void {
2271
2271
forEach ( symbols , symbol => {
2272
- var entry = createCompletionEntry ( symbol ) ;
2272
+ var entry = createCompletionEntry ( symbol , session . typeChecker ) ;
2273
2273
if ( entry && ! lookUp ( session . symbols , entry . name ) ) {
2274
2274
session . entries . push ( entry ) ;
2275
2275
session . symbols [ entry . name ] = symbol ;
@@ -2608,7 +2608,7 @@ module ts {
2608
2608
if ( symbol ) {
2609
2609
var type = session . typeChecker . getTypeOfSymbol ( symbol ) ;
2610
2610
Debug . assert ( type , "Could not find type for symbol" ) ;
2611
- var completionEntry = createCompletionEntry ( symbol ) ;
2611
+ var completionEntry = createCompletionEntry ( symbol , session . typeChecker ) ;
2612
2612
// TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind'
2613
2613
// which is permissible given that it is backwards compatible; but really we should consider
2614
2614
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
@@ -2657,15 +2657,15 @@ module ts {
2657
2657
}
2658
2658
2659
2659
// TODO(drosen): use contextual SemanticMeaning.
2660
- function getSymbolKind ( symbol : Symbol ) : string {
2660
+ function getSymbolKind ( symbol : Symbol , typeResolver : TypeChecker ) : string {
2661
2661
var flags = typeInfoResolver . getRootSymbol ( symbol ) . getFlags ( ) ;
2662
2662
2663
2663
if ( flags & SymbolFlags . Class ) return ScriptElementKind . classElement ;
2664
2664
if ( flags & SymbolFlags . Enum ) return ScriptElementKind . enumElement ;
2665
2665
if ( flags & SymbolFlags . Interface ) return ScriptElementKind . interfaceElement ;
2666
2666
if ( flags & SymbolFlags . TypeParameter ) return ScriptElementKind . typeParameterElement ;
2667
2667
2668
- var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , flags ) ;
2668
+ var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , flags , typeResolver ) ;
2669
2669
if ( result === ScriptElementKind . unknown ) {
2670
2670
if ( flags & SymbolFlags . TypeParameter ) return ScriptElementKind . typeParameterElement ;
2671
2671
if ( flags & SymbolFlags . EnumMember ) return ScriptElementKind . variableElement ;
@@ -2675,16 +2675,19 @@ module ts {
2675
2675
return result ;
2676
2676
}
2677
2677
2678
- function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol : Symbol , flags : SymbolFlags ) {
2678
+ function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol : Symbol , flags : SymbolFlags , typeResolver : TypeChecker ) {
2679
+ if ( typeResolver . isUndefinedSymbol ( symbol ) ) {
2680
+ return ScriptElementKind . variableElement ;
2681
+ }
2682
+ if ( typeResolver . isArgumentsSymbol ( symbol ) ) {
2683
+ return ScriptElementKind . localVariableElement ;
2684
+ }
2679
2685
if ( flags & SymbolFlags . Variable ) {
2680
2686
if ( isFirstDeclarationOfSymbolParameter ( symbol ) ) {
2681
2687
return ScriptElementKind . parameterElement ;
2682
2688
}
2683
2689
return isLocalVariableOrFunction ( symbol ) ? ScriptElementKind . localVariableElement : ScriptElementKind . variableElement ;
2684
2690
}
2685
- if ( flags & SymbolFlags . Undefined ) {
2686
- return ScriptElementKind . variableElement ;
2687
- }
2688
2691
if ( flags & SymbolFlags . Function ) return isLocalVariableOrFunction ( symbol ) ? ScriptElementKind . localFunctionElement : ScriptElementKind . functionElement ;
2689
2692
if ( flags & SymbolFlags . GetAccessor ) return ScriptElementKind . memberGetAccessorElement ;
2690
2693
if ( flags & SymbolFlags . SetAccessor ) return ScriptElementKind . memberSetAccessorElement ;
@@ -2746,7 +2749,7 @@ module ts {
2746
2749
var displayParts : SymbolDisplayPart [ ] = [ ] ;
2747
2750
var documentation : SymbolDisplayPart [ ] ;
2748
2751
var symbolFlags = typeResolver . getRootSymbol ( symbol ) . flags ;
2749
- var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , symbolFlags ) ;
2752
+ var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , symbolFlags , typeResolver ) ;
2750
2753
var hasAddedSymbolInfo : boolean ;
2751
2754
// Class at constructor site need to be shown as constructor apart from property,method, vars
2752
2755
if ( symbolKind !== ScriptElementKind . unknown || symbolFlags & SymbolFlags . Class || symbolFlags & SymbolFlags . Import ) {
@@ -2952,8 +2955,10 @@ module ts {
2952
2955
if ( symbolKind !== ScriptElementKind . unknown ) {
2953
2956
if ( type ) {
2954
2957
addPrefixForAnyFunctionOrVar ( symbol , symbolKind ) ;
2958
+ // For properties, variables and local vars: show the type
2955
2959
if ( symbolKind === ScriptElementKind . memberVariableElement ||
2956
- symbolFlags & SymbolFlags . Variable ) {
2960
+ symbolFlags & SymbolFlags . Variable ||
2961
+ symbolKind === ScriptElementKind . localVariableElement ) {
2957
2962
displayParts . push ( punctuationPart ( SyntaxKind . ColonToken ) ) ;
2958
2963
displayParts . push ( spacePart ( ) ) ;
2959
2964
// If the type is type parameter, format it specially
@@ -2978,7 +2983,7 @@ module ts {
2978
2983
}
2979
2984
}
2980
2985
else {
2981
- symbolKind = getSymbolKind ( symbol ) ;
2986
+ symbolKind = getSymbolKind ( symbol , typeResolver ) ;
2982
2987
}
2983
2988
}
2984
2989
@@ -3184,7 +3189,7 @@ module ts {
3184
3189
3185
3190
var declarations = symbol . getDeclarations ( ) ;
3186
3191
var symbolName = typeInfoResolver . symbolToString ( symbol ) ; // Do not get scoped name, just the name of the symbol
3187
- var symbolKind = getSymbolKind ( symbol ) ;
3192
+ var symbolKind = getSymbolKind ( symbol , typeInfoResolver ) ;
3188
3193
var containerSymbol = symbol . parent ;
3189
3194
var containerName = containerSymbol ? typeInfoResolver . symbolToString ( containerSymbol , node ) : "" ;
3190
3195
@@ -5175,7 +5180,7 @@ module ts {
5175
5180
5176
5181
// Only allow a symbol to be renamed if it actually has at least one declaration.
5177
5182
if ( symbol && symbol . getDeclarations ( ) && symbol . getDeclarations ( ) . length > 0 ) {
5178
- var kind = getSymbolKind ( symbol ) ;
5183
+ var kind = getSymbolKind ( symbol , typeInfoResolver ) ;
5179
5184
if ( kind ) {
5180
5185
return getRenameInfo ( symbol . name , typeInfoResolver . getFullyQualifiedName ( symbol ) , kind ,
5181
5186
getSymbolModifiers ( symbol ) ,
0 commit comments