@@ -2259,13 +2259,9 @@ module ts {
2259
2259
return undefined ;
2260
2260
}
2261
2261
2262
- // TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind'
2263
- // which is permissible given that it is backwards compatible; but really we should consider
2264
- // passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
2265
- // We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
2266
2262
return {
2267
2263
name : displayName ,
2268
- kind : getSymbolKind ( symbol , SemanticMeaning . All ) ,
2264
+ kind : getSymbolKind ( symbol ) ,
2269
2265
kindModifiers : getSymbolModifiers ( symbol )
2270
2266
} ;
2271
2267
}
@@ -2617,7 +2613,7 @@ module ts {
2617
2613
// which is permissible given that it is backwards compatible; but really we should consider
2618
2614
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
2619
2615
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
2620
- var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind ( symbol , getSourceFile ( filename ) , session . location , session . typeChecker , session . location , SemanticMeaning . All ) ;
2616
+ var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind ( symbol , getSourceFile ( filename ) , session . location , session . typeChecker , session . location ) ;
2621
2617
return {
2622
2618
name : entryName ,
2623
2619
kind : displayPartsDocumentationsAndSymbolKind . symbolKind ,
@@ -2660,19 +2656,15 @@ module ts {
2660
2656
}
2661
2657
}
2662
2658
2663
- function getSymbolKind ( symbol : Symbol , meaningAtLocation : SemanticMeaning ) : string {
2659
+ // TODO(drosen): use contextual SemanticMeaning.
2660
+ function getSymbolKind ( symbol : Symbol ) : string {
2664
2661
var flags = typeInfoResolver . getRootSymbol ( symbol ) . getFlags ( ) ;
2665
2662
2666
2663
if ( flags & SymbolFlags . Class ) return ScriptElementKind . classElement ;
2667
2664
if ( flags & SymbolFlags . Enum ) return ScriptElementKind . enumElement ;
2668
-
2669
- // The following should only apply if encountered at a type position,
2670
- // and need to have precedence over other meanings if this is the case.
2671
- if ( meaningAtLocation & SemanticMeaning . Type ) {
2672
- if ( flags & SymbolFlags . Interface ) return ScriptElementKind . interfaceElement ;
2673
- if ( flags & SymbolFlags . TypeParameter ) return ScriptElementKind . typeParameterElement ;
2674
- }
2675
-
2665
+ if ( flags & SymbolFlags . Interface ) return ScriptElementKind . interfaceElement ;
2666
+ if ( flags & SymbolFlags . TypeParameter ) return ScriptElementKind . typeParameterElement ;
2667
+
2676
2668
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , flags ) ;
2677
2669
if ( result === ScriptElementKind . unknown ) {
2678
2670
if ( flags & SymbolFlags . TypeParameter ) return ScriptElementKind . typeParameterElement ;
@@ -2745,10 +2737,12 @@ module ts {
2745
2737
: ScriptElementKindModifier . none ;
2746
2738
}
2747
2739
2748
- function getSymbolDisplayPartsDocumentationAndSymbolKind ( symbol : Symbol , sourceFile : SourceFile , enclosingDeclaration : Node ,
2749
- typeResolver : TypeChecker , location : Node ,
2750
- // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
2751
- semanticMeaning = getMeaningFromLocation ( location ) ) {
2740
+ // TODO(drosen): use contextual SemanticMeaning.
2741
+ function getSymbolDisplayPartsDocumentationAndSymbolKind ( symbol : Symbol ,
2742
+ sourceFile : SourceFile ,
2743
+ enclosingDeclaration : Node ,
2744
+ typeResolver : TypeChecker ,
2745
+ location : Node ) {
2752
2746
var displayParts : SymbolDisplayPart [ ] = [ ] ;
2753
2747
var documentation : SymbolDisplayPart [ ] ;
2754
2748
var symbolFlags = typeResolver . getRootSymbol ( symbol ) . flags ;
@@ -2853,13 +2847,14 @@ module ts {
2853
2847
}
2854
2848
}
2855
2849
}
2850
+
2856
2851
if ( symbolFlags & SymbolFlags . Class && ! hasAddedSymbolInfo ) {
2857
2852
displayParts . push ( keywordPart ( SyntaxKind . ClassKeyword ) ) ;
2858
2853
displayParts . push ( spacePart ( ) ) ;
2859
2854
displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile , /*meaning*/ undefined , SymbolFormatFlags . WriteTypeParametersOrArguments ) ) ;
2860
2855
writeTypeParametersOfSymbol ( symbol , sourceFile ) ;
2861
2856
}
2862
- if ( ( symbolFlags & SymbolFlags . Interface ) && ( semanticMeaning & SemanticMeaning . Type ) ) {
2857
+ if ( symbolFlags & SymbolFlags . Interface ) {
2863
2858
addNewLineIfDisplayPartsExist ( ) ;
2864
2859
displayParts . push ( keywordPart ( SyntaxKind . InterfaceKeyword ) ) ;
2865
2860
displayParts . push ( spacePart ( ) ) ;
@@ -2878,7 +2873,7 @@ module ts {
2878
2873
displayParts . push ( spacePart ( ) ) ;
2879
2874
displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile ) ) ;
2880
2875
}
2881
- if ( ( symbolFlags & SymbolFlags . TypeParameter ) && ( semanticMeaning & SemanticMeaning . Type ) ) {
2876
+ if ( symbolFlags & SymbolFlags . TypeParameter ) {
2882
2877
addNewLineIfDisplayPartsExist ( ) ;
2883
2878
displayParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2884
2879
displayParts . push ( textPart ( "type parameter" ) ) ;
@@ -2958,7 +2953,7 @@ module ts {
2958
2953
}
2959
2954
}
2960
2955
else {
2961
- symbolKind = getSymbolKind ( symbol , semanticMeaning ) ;
2956
+ symbolKind = getSymbolKind ( symbol ) ;
2962
2957
}
2963
2958
}
2964
2959
@@ -3159,7 +3154,7 @@ module ts {
3159
3154
3160
3155
var declarations = symbol . getDeclarations ( ) ;
3161
3156
var symbolName = typeInfoResolver . symbolToString ( symbol ) ; // Do not get scoped name, just the name of the symbol
3162
- var symbolKind = getSymbolKind ( symbol , getMeaningFromLocation ( node ) ) ;
3157
+ var symbolKind = getSymbolKind ( symbol ) ;
3163
3158
var containerSymbol = symbol . parent ;
3164
3159
var containerName = containerSymbol ? typeInfoResolver . symbolToString ( containerSymbol , node ) : "" ;
3165
3160
@@ -4661,19 +4656,18 @@ module ts {
4661
4656
function classifySymbol ( symbol : Symbol , meaningAtPosition : SemanticMeaning ) {
4662
4657
var flags = symbol . getFlags ( ) ;
4663
4658
4659
+ // TODO(drosen): use meaningAtPosition.
4664
4660
if ( flags & SymbolFlags . Class ) {
4665
4661
return ClassificationTypeNames . className ;
4666
4662
}
4667
4663
else if ( flags & SymbolFlags . Enum ) {
4668
4664
return ClassificationTypeNames . enumName ;
4669
4665
}
4670
- else if ( meaningAtPosition & SemanticMeaning . Type ) {
4671
- if ( flags & SymbolFlags . Interface ) {
4672
- return ClassificationTypeNames . interfaceName ;
4673
- }
4674
- else if ( flags & SymbolFlags . TypeParameter ) {
4675
- return ClassificationTypeNames . typeParameterName ;
4676
- }
4666
+ else if ( flags & SymbolFlags . Interface ) {
4667
+ return ClassificationTypeNames . interfaceName ;
4668
+ }
4669
+ else if ( flags & SymbolFlags . TypeParameter ) {
4670
+ return ClassificationTypeNames . typeParameterName ;
4677
4671
}
4678
4672
else if ( flags & SymbolFlags . Module ) {
4679
4673
return ClassificationTypeNames . moduleName ;
@@ -5147,7 +5141,7 @@ module ts {
5147
5141
5148
5142
// Only allow a symbol to be renamed if it actually has at least one declaration.
5149
5143
if ( symbol && symbol . getDeclarations ( ) && symbol . getDeclarations ( ) . length > 0 ) {
5150
- var kind = getSymbolKind ( symbol , getMeaningFromLocation ( node ) ) ;
5144
+ var kind = getSymbolKind ( symbol ) ;
5151
5145
if ( kind ) {
5152
5146
return getRenameInfo ( symbol . name , typeInfoResolver . getFullyQualifiedName ( symbol ) , kind ,
5153
5147
getSymbolModifiers ( symbol ) ,
0 commit comments