Don't intern all strings and numbers. Just the ones used as declaration names.

This commit is contained in:
Cyrus Najmabadi
2015-03-01 11:35:31 -08:00
parent 419d379912
commit b58f16b021

View File

@@ -4044,7 +4044,16 @@ module ts {
break;
case SyntaxKind.StringLiteral:
case SyntaxKind.NumericLiteral:
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
// We want to store any numbers/strings if they were a name that could be
// related to a declaration. So, if we have 'import x = require("something")'
// then we want 'something' to be in the name table. Similarly, if we have
// "a['propname']" then we want to store "propname" in the name table.
if (isDeclarationName(node) ||
node.parent.kind === SyntaxKind.ExternalModuleReference ||
isArgumentOfElementAccessExpression(node)) {
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
}
break;
default:
forEachChild(node, walk);
@@ -4052,6 +4061,13 @@ module ts {
}
}
function isArgumentOfElementAccessExpression(node: Node) {
return node &&
node.parent &&
node.parent.kind === SyntaxKind.ElementAccessExpression &&
(<ElementAccessExpression>node.parent).argumentExpression === node;
}
function getReferencesForNode(node: Node, sourceFiles: SourceFile[], searchOnlyInCurrentFile: boolean, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
// Labels
if (isLabelName(node)) {