mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
committed by
unknown
parent
393be4687c
commit
175dba4977
@@ -33,6 +33,7 @@ module ts {
|
||||
var container: Declaration;
|
||||
var lastContainer: Declaration;
|
||||
var symbolCount = 0;
|
||||
var lastLocals: Declaration;
|
||||
var Symbol = objectAllocator.getSymbolConstructor();
|
||||
|
||||
if (!file.locals) {
|
||||
|
||||
@@ -6049,6 +6049,49 @@ module ts {
|
||||
Debug.fail("getLocalNameForSymbol failed");
|
||||
}
|
||||
|
||||
function isNodeParentedBy(node: Node, parent: Node): boolean {
|
||||
while (node) {
|
||||
if (node === parent) return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isUniqueLocalName(name: string, container: Node): boolean {
|
||||
name = escapeIdentifier(name);
|
||||
if (container.locals) {
|
||||
for (var node = container; isNodeParentedBy(node, container); node = node.nextLocals) {
|
||||
if (hasProperty(node.locals, name) && node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getLocalNameOfContainer(container: Declaration): string {
|
||||
var links = getNodeLinks(container);
|
||||
if (!links.localModuleName) {
|
||||
var name = container.name.text ? unescapeIdentifier(container.name.text) : "M";
|
||||
while (!isUniqueLocalName(name, container)) {
|
||||
name = "_" + name;
|
||||
}
|
||||
links.localModuleName = name;
|
||||
}
|
||||
return links.localModuleName;
|
||||
}
|
||||
|
||||
function getLocalNameForSymbol(symbol: Symbol, location: Node): string {
|
||||
var node = location;
|
||||
while (node) {
|
||||
if ((node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(node) === symbol) {
|
||||
return getLocalNameOfContainer(node);
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
Debug.fail("getLocalNameForSymbol failed");
|
||||
}
|
||||
|
||||
function getExpressionNamePrefix(node: Identifier): string {
|
||||
var symbol = getNodeLinks(node).resolvedSymbol;
|
||||
if (symbol) {
|
||||
|
||||
@@ -691,7 +691,7 @@ module ts {
|
||||
|
||||
ExportHasLocal = Function | Class | Enum | ValueModule,
|
||||
|
||||
HasLocals = Function | Module | Method | Constructor | Accessor | Signature,
|
||||
HasLocals = Function | Enum | Module | Method | Constructor | Accessor | Signature,
|
||||
HasExports = Class | Enum | Module,
|
||||
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user