@@ -4915,25 +4915,20 @@ module ts {
4915
4915
return undefined ;
4916
4916
}
4917
4917
4918
-
4919
4918
let declarations = symbol . declarations ;
4920
4919
4921
4920
// The symbol was an internal symbol and does not have a declaration e.g. undefined symbol
4922
4921
if ( ! declarations || ! declarations . length ) {
4923
4922
return undefined ;
4924
4923
}
4925
4924
4926
- // Try to get the local symbol if we're dealing with an 'export default'
4927
- // since that symbol has the "true" name and we need to account for other declarations.
4928
- let localExportDefaultSymbol = getLocalSymbolForExportDefault ( symbol ) ;
4929
-
4930
4925
let result : ReferencedSymbol [ ] ;
4931
4926
4932
4927
// Compute the meaning from the location and the symbol it references
4933
4928
let searchMeaning = getIntersectingMeaningFromDeclarations ( getMeaningFromLocation ( node ) , declarations ) ;
4934
4929
4935
4930
// Get the text to search for, we need to normalize it as external module names will have quotes
4936
- let declaredName = getDeclaredName ( localExportDefaultSymbol || symbol , node ) ;
4931
+ let declaredName = getDeclaredName ( typeChecker , symbol , node ) ;
4937
4932
4938
4933
// Try to get the smallest valid scope that we can limit our search to;
4939
4934
// otherwise we'll need to search globally (i.e. include each file).
@@ -4947,7 +4942,7 @@ module ts {
4947
4942
getReferencesInNode ( scope , symbol , declaredName , node , searchMeaning , findInStrings , findInComments , result , symbolToIndex ) ;
4948
4943
}
4949
4944
else {
4950
- let internedName = getInternedName ( localExportDefaultSymbol || symbol , node , declarations )
4945
+ let internedName = getInternedName ( symbol , node , declarations )
4951
4946
for ( let sourceFile of sourceFiles ) {
4952
4947
cancellationToken . throwIfCancellationRequested ( ) ;
4953
4948
@@ -4980,30 +4975,12 @@ module ts {
4980
4975
} ;
4981
4976
}
4982
4977
4983
- function isImportOrExportSpecifierName ( location : Node ) : boolean {
4984
- return location . parent &&
4985
- ( location . parent . kind === SyntaxKind . ImportSpecifier || location . parent . kind === SyntaxKind . ExportSpecifier ) &&
4986
- ( < ImportOrExportSpecifier > location . parent ) . propertyName === location ;
4987
- }
4988
-
4989
4978
function isImportOrExportSpecifierImportSymbol ( symbol : Symbol ) {
4990
4979
return ( symbol . flags & SymbolFlags . Alias ) && forEach ( symbol . declarations , declaration => {
4991
4980
return declaration . kind === SyntaxKind . ImportSpecifier || declaration . kind === SyntaxKind . ExportSpecifier ;
4992
4981
} ) ;
4993
4982
}
4994
4983
4995
- function getDeclaredName ( symbol : Symbol , location : Node ) {
4996
- // If this is an export or import specifier it could have been renamed using the 'as' syntax.
4997
- // If so we want to search for whatever is under the cursor.
4998
- if ( isImportOrExportSpecifierName ( location ) ) {
4999
- return location . getText ( ) ;
5000
- }
5001
-
5002
- let name = typeChecker . symbolToString ( symbol ) ;
5003
-
5004
- return stripQuotes ( name ) ;
5005
- }
5006
-
5007
4984
function getInternedName ( symbol : Symbol , location : Node , declarations : Declaration [ ] ) {
5008
4985
// If this is an export or import specifier it could have been renamed using the 'as' syntax.
5009
4986
// If so we want to search for whatever under the cursor.
@@ -5023,15 +5000,12 @@ module ts {
5023
5000
}
5024
5001
}
5025
5002
5026
- return stripQuotes ( symbol . name ) ;
5027
- }
5003
+ // Try to get the local symbol if we're dealing with an 'export default'
5004
+ // since that symbol has the "true" name.
5005
+ let localExportDefaultSymbol = getLocalSymbolForExportDefault ( symbol ) ;
5006
+ symbol = localExportDefaultSymbol || symbol ;
5028
5007
5029
- function stripQuotes ( name : string ) {
5030
- let length = name . length ;
5031
- if ( length >= 2 && name . charCodeAt ( 0 ) === CharacterCodes . doubleQuote && name . charCodeAt ( length - 1 ) === CharacterCodes . doubleQuote ) {
5032
- return name . substring ( 1 , length - 1 ) ;
5033
- } ;
5034
- return name ;
5008
+ return stripQuotes ( symbol . name ) ;
5035
5009
}
5036
5010
5037
5011
function getSymbolScope ( symbol : Symbol ) : Node {
@@ -6647,12 +6621,13 @@ module ts {
6647
6621
}
6648
6622
}
6649
6623
6624
+ let displayName = getDeclaredName ( typeChecker , symbol , node ) ;
6650
6625
let kind = getSymbolKind ( symbol , node ) ;
6651
6626
if ( kind ) {
6652
6627
return {
6653
6628
canRename : true ,
6654
6629
localizedErrorMessage : undefined ,
6655
- displayName : symbol . name ,
6630
+ displayName,
6656
6631
fullDisplayName : typeChecker . getFullyQualifiedName ( symbol ) ,
6657
6632
kind : kind ,
6658
6633
kindModifiers : getSymbolModifiers ( symbol ) ,
0 commit comments