Cleaning up a few things

This commit is contained in:
Anders Hejlsberg
2015-02-06 13:50:30 -08:00
parent 6d0db0f401
commit 930d11bc82
2 changed files with 9 additions and 31 deletions

View File

@@ -4880,11 +4880,13 @@ module ts {
var symbol = getResolvedSymbol(node);
if (symbol.flags & SymbolFlags.Import) {
var symbolLinks = getSymbolLinks(symbol);
symbolLinks.referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol));
// TODO(andersh): Figure out what this does
// TODO: AndersH: This needs to be simplified. In an import of the form "import x = a.b.c;" we only need
// to resolve "a" and mark it as referenced. If "b" and/or "c" are aliases, we would be able to access them
// unless they're exported, and in that case they're already implicitly referenced.
//var symbolLinks = getSymbolLinks(symbol);
//if (!symbolLinks.referenced) {
// var importOrExportAssignment = getLeftSideOfImportEqualsOrExportAssignment(node);

View File

@@ -753,36 +753,12 @@ module ts {
}
export function getAncestor(node: Node, kind: SyntaxKind): Node {
switch (kind) {
// special-cases that can be come first
case SyntaxKind.ClassDeclaration:
while (node) {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
return <ClassDeclaration>node;
case SyntaxKind.EnumDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
// early exit cases - declarations cannot be nested in classes
return undefined;
default:
node = node.parent;
continue;
}
}
break;
default:
while (node) {
if (node.kind === kind) {
return node;
}
node = node.parent;
}
break;
while (node) {
if (node.kind === kind) {
return node;
}
node = node.parent;
}
return undefined;
}