@@ -4988,18 +4988,6 @@ module ts {
4988
4988
return location . getText ( ) ;
4989
4989
}
4990
4990
4991
- // Special case for function expressions, whose names are solely local to their bodies.
4992
- // TODO (drosen): Why would we have to lookup the interned name for a function expression?
4993
- // Shouldn't we have found a scope? Consider a 'Debug.fail()'.
4994
- let functionExpression : FunctionExpression ;
4995
- if ( symbol . valueDeclaration && symbol . valueDeclaration . kind === SyntaxKind . FunctionExpression ) {
4996
- functionExpression = < FunctionExpression > symbol . valueDeclaration ;
4997
-
4998
- if ( functionExpression . name ) {
4999
- return functionExpression . name . text ;
5000
- }
5001
- }
5002
-
5003
4991
// Try to get the local symbol if we're dealing with an 'export default'
5004
4992
// since that symbol has the "true" name.
5005
4993
let localExportDefaultSymbol = getLocalSymbolForExportDefault ( symbol ) ;
@@ -5008,7 +4996,20 @@ module ts {
5008
4996
return stripQuotes ( symbol . name ) ;
5009
4997
}
5010
4998
4999
+ /**
5000
+ * Determines the smallest scope in which a symbol may have named references.
5001
+ *
5002
+ * Returns undefined if the scope cannot be determined, often implying that
5003
+ * a reference to a symbol can occur anywhere.
5004
+ */
5011
5005
function getSymbolScope ( symbol : Symbol ) : Node {
5006
+ // If this is the symbol of a function expression, then named references
5007
+ // are limited to its own scope.
5008
+ let valueDeclaration = symbol . valueDeclaration ;
5009
+ if ( valueDeclaration && valueDeclaration . kind === SyntaxKind . FunctionExpression ) {
5010
+ return valueDeclaration ;
5011
+ }
5012
+
5012
5013
// If this is private property or method, the scope is the containing class
5013
5014
if ( symbol . flags & ( SymbolFlags . Property | SymbolFlags . Method ) ) {
5014
5015
let privateDeclaration = forEach ( symbol . getDeclarations ( ) , d => ( d . flags & NodeFlags . Private ) ? d : undefined ) ;
0 commit comments