@@ -2749,15 +2749,11 @@ module ts {
2749
2749
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , symbolFlags ) ;
2750
2750
var hasAddedSymbolInfo : boolean ;
2751
2751
// Class at constructor site need to be shown as constructor apart from property,method, vars
2752
- if ( symbolKind !== ScriptElementKind . unknown || symbolFlags & SymbolFlags . Signature || symbolFlags & SymbolFlags . Class ) {
2752
+ if ( symbolKind !== ScriptElementKind . unknown || symbolFlags & SymbolFlags . Class || symbolFlags & SymbolFlags . Import ) {
2753
2753
// If it is accessor they are allowed only if location is at name of the accessor
2754
2754
if ( symbolKind === ScriptElementKind . memberGetAccessorElement || symbolKind === ScriptElementKind . memberSetAccessorElement ) {
2755
2755
symbolKind = ScriptElementKind . memberVariableElement ;
2756
2756
}
2757
- else if ( symbol . name === "undefined" ) {
2758
- // undefined is symbol and not property
2759
- symbolKind = ScriptElementKind . variableElement ;
2760
- }
2761
2757
2762
2758
var type = typeResolver . getTypeOfSymbol ( symbol ) ;
2763
2759
if ( type ) {
@@ -2790,6 +2786,18 @@ module ts {
2790
2786
symbolKind = ScriptElementKind . constructorImplementationElement ;
2791
2787
addPrefixForAnyFunctionOrVar ( type . symbol , symbolKind ) ;
2792
2788
}
2789
+ else if ( symbolFlags & SymbolFlags . Import ) {
2790
+ symbolKind = ScriptElementKind . alias ;
2791
+ displayParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2792
+ displayParts . push ( textPart ( symbolKind ) ) ;
2793
+ displayParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2794
+ displayParts . push ( spacePart ( ) ) ;
2795
+ if ( useConstructSignatures ) {
2796
+ displayParts . push ( keywordPart ( SyntaxKind . NewKeyword ) ) ;
2797
+ displayParts . push ( spacePart ( ) ) ;
2798
+ }
2799
+ addFullSymbolName ( symbol ) ;
2800
+ }
2793
2801
else {
2794
2802
addPrefixForAnyFunctionOrVar ( symbol , symbolKind ) ;
2795
2803
}
@@ -2851,41 +2859,41 @@ module ts {
2851
2859
if ( symbolFlags & SymbolFlags . Class && ! hasAddedSymbolInfo ) {
2852
2860
displayParts . push ( keywordPart ( SyntaxKind . ClassKeyword ) ) ;
2853
2861
displayParts . push ( spacePart ( ) ) ;
2854
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile , /*meaning*/ undefined , SymbolFormatFlags . WriteTypeParametersOrArguments ) ) ;
2862
+ addFullSymbolName ( symbol ) ;
2855
2863
writeTypeParametersOfSymbol ( symbol , sourceFile ) ;
2856
2864
}
2857
2865
if ( symbolFlags & SymbolFlags . Interface ) {
2858
2866
addNewLineIfDisplayPartsExist ( ) ;
2859
2867
displayParts . push ( keywordPart ( SyntaxKind . InterfaceKeyword ) ) ;
2860
2868
displayParts . push ( spacePart ( ) ) ;
2861
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile , /*meaning*/ undefined , SymbolFormatFlags . WriteTypeParametersOrArguments ) ) ;
2869
+ addFullSymbolName ( symbol ) ;
2862
2870
writeTypeParametersOfSymbol ( symbol , sourceFile ) ;
2863
2871
}
2864
2872
if ( symbolFlags & SymbolFlags . Enum ) {
2865
2873
addNewLineIfDisplayPartsExist ( ) ;
2866
2874
displayParts . push ( keywordPart ( SyntaxKind . EnumKeyword ) ) ;
2867
2875
displayParts . push ( spacePart ( ) ) ;
2868
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile ) ) ;
2876
+ addFullSymbolName ( symbol ) ;
2869
2877
}
2870
2878
if ( symbolFlags & SymbolFlags . Module ) {
2871
2879
addNewLineIfDisplayPartsExist ( ) ;
2872
2880
displayParts . push ( keywordPart ( SyntaxKind . ModuleKeyword ) ) ;
2873
2881
displayParts . push ( spacePart ( ) ) ;
2874
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile ) ) ;
2882
+ addFullSymbolName ( symbol ) ;
2875
2883
}
2876
2884
if ( symbolFlags & SymbolFlags . TypeParameter ) {
2877
2885
addNewLineIfDisplayPartsExist ( ) ;
2878
2886
displayParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2879
2887
displayParts . push ( textPart ( "type parameter" ) ) ;
2880
2888
displayParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2881
2889
displayParts . push ( spacePart ( ) ) ;
2882
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , enclosingDeclaration ) ) ;
2890
+ addFullSymbolName ( symbol ) ;
2883
2891
displayParts . push ( spacePart ( ) ) ;
2884
2892
displayParts . push ( keywordPart ( SyntaxKind . InKeyword ) ) ;
2885
2893
displayParts . push ( spacePart ( ) ) ;
2886
2894
if ( symbol . parent ) {
2887
2895
// Class/Interface type parameter
2888
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol . parent , enclosingDeclaration , /*meaning*/ undefined , SymbolFormatFlags . WriteTypeParametersOrArguments ) )
2896
+ addFullSymbolName ( symbol . parent , enclosingDeclaration ) ;
2889
2897
writeTypeParametersOfSymbol ( symbol . parent , enclosingDeclaration ) ;
2890
2898
}
2891
2899
else {
@@ -2897,7 +2905,7 @@ module ts {
2897
2905
displayParts . push ( spacePart ( ) ) ;
2898
2906
}
2899
2907
else if ( signatureDeclaration . kind !== SyntaxKind . CallSignature && signatureDeclaration . name ) {
2900
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , signatureDeclaration . symbol , sourceFile , /*meaning*/ undefined , SymbolFormatFlags . WriteTypeParametersOrArguments ) )
2908
+ addFullSymbolName ( signatureDeclaration . symbol ) ;
2901
2909
}
2902
2910
displayParts . push . apply ( displayParts , signatureToDisplayParts ( typeResolver , signature , sourceFile , TypeFormatFlags . WriteTypeArgumentsOfSignature ) ) ;
2903
2911
}
@@ -2917,11 +2925,28 @@ module ts {
2917
2925
}
2918
2926
if ( symbolFlags & SymbolFlags . Import ) {
2919
2927
addNewLineIfDisplayPartsExist ( ) ;
2920
- displayParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2921
- displayParts . push ( textPart ( "alias" ) ) ;
2922
- displayParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2928
+ displayParts . push ( keywordPart ( SyntaxKind . ImportKeyword ) ) ;
2929
+ displayParts . push ( spacePart ( ) ) ;
2930
+ addFullSymbolName ( symbol ) ;
2931
+ displayParts . push ( spacePart ( ) ) ;
2932
+ displayParts . push ( punctuationPart ( SyntaxKind . EqualsToken ) ) ;
2923
2933
displayParts . push ( spacePart ( ) ) ;
2924
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile ) ) ;
2934
+ ts . forEach ( symbol . declarations , declaration => {
2935
+ if ( declaration . kind === SyntaxKind . ImportDeclaration ) {
2936
+ var importDeclaration = < ImportDeclaration > declaration ;
2937
+ if ( importDeclaration . externalModuleName ) {
2938
+ displayParts . push ( keywordPart ( SyntaxKind . RequireKeyword ) ) ;
2939
+ displayParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2940
+ displayParts . push ( displayPart ( getTextOfNode ( importDeclaration . externalModuleName ) , SymbolDisplayPartKind . stringLiteral ) ) ;
2941
+ displayParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2942
+ }
2943
+ else {
2944
+ var internalAliasSymbol = typeResolver . getSymbolInfo ( importDeclaration . entityName ) ;
2945
+ addFullSymbolName ( internalAliasSymbol , enclosingDeclaration ) ;
2946
+ }
2947
+ return true ;
2948
+ }
2949
+ } ) ;
2925
2950
}
2926
2951
if ( ! hasAddedSymbolInfo ) {
2927
2952
if ( symbolKind !== ScriptElementKind . unknown ) {
@@ -2969,15 +2994,20 @@ module ts {
2969
2994
}
2970
2995
}
2971
2996
2997
+ function addFullSymbolName ( symbol : Symbol , enclosingDeclaration ?: Node ) {
2998
+ var fullSymbolDisplayParts = symbolToDisplayParts ( typeResolver , symbol , enclosingDeclaration || sourceFile , /*meaning*/ undefined ,
2999
+ SymbolFormatFlags . WriteTypeParametersOrArguments | SymbolFormatFlags . UseOnlyExternalAliasing ) ;
3000
+ displayParts . push . apply ( displayParts , fullSymbolDisplayParts ) ;
3001
+ }
3002
+
2972
3003
function addPrefixForAnyFunctionOrVar ( symbol : Symbol , symbolKind : string ) {
2973
3004
addNewLineIfDisplayPartsExist ( ) ;
2974
3005
if ( symbolKind ) {
2975
3006
displayParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2976
3007
displayParts . push ( textPart ( symbolKind ) ) ;
2977
3008
displayParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2978
3009
displayParts . push ( spacePart ( ) ) ;
2979
- // Write type parameters of class/Interface if it is property/method of the generic class/interface
2980
- displayParts . push . apply ( displayParts , symbolToDisplayParts ( typeResolver , symbol , sourceFile , /*meaning*/ undefined , SymbolFormatFlags . WriteTypeParametersOrArguments ) ) ;
3010
+ addFullSymbolName ( symbol ) ;
2981
3011
}
2982
3012
}
2983
3013
@@ -3023,7 +3053,7 @@ module ts {
3023
3053
case SyntaxKind . QualifiedName :
3024
3054
case SyntaxKind . ThisKeyword :
3025
3055
case SyntaxKind . SuperKeyword :
3026
- // For the identifiers/this/usper etc get the type at position
3056
+ // For the identifiers/this/super etc get the type at position
3027
3057
var type = typeInfoResolver . getTypeOfNode ( node ) ;
3028
3058
if ( type ) {
3029
3059
return {
0 commit comments