Respond to code review remarks

This commit is contained in:
Mohamed Hegazy 2015-03-31 21:17:24 -07:00
parent 383f01dbf6
commit 0c5d736251
3 changed files with 17 additions and 10 deletions

View file

@ -351,7 +351,8 @@ module ts {
}
else if (location.kind === SyntaxKind.SourceFile) {
result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & SymbolFlags.ModuleMember);
if (result && (result.flags & meaning) && result.valueDeclaration && (result.valueDeclaration.flags & NodeFlags.Default) && result.valueDeclaration.localSymbol.name === name) {
let localSymbol = getLocalSymbolForExportDefault(result);
if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) {
break loop;
}
result = undefined;

View file

@ -145,7 +145,7 @@ module ts {
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
}
export function nodeIsPresent(node: Node) {
return !nodeIsMissing(node);
}
@ -288,7 +288,7 @@ module ts {
errorNode = (<Declaration>node).name;
break;
}
if (errorNode === undefined) {
// If we don't have a better node, then just set the error on the first token of
// construct.
@ -634,7 +634,7 @@ module ts {
return false;
}
export function childIsDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
@ -745,7 +745,7 @@ module ts {
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
let moduleState = getModuleInstanceState(node)
return moduleState === ModuleInstanceState.Instantiated ||
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
}
export function isExternalModuleImportEqualsDeclaration(node: Node) {
@ -1161,7 +1161,7 @@ module ts {
export function createTextSpanFromBounds(start: number, end: number) {
return createTextSpan(start, end - start);
}
export function textChangeRangeNewSpan(range: TextChangeRange) {
return createTextSpan(range.span.start, range.newLength);
}
@ -1435,13 +1435,13 @@ module ts {
return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0));
}
}
function get16BitUnicodeEscapeSequence(charCode: number): string {
let hexCharCode = charCode.toString(16).toUpperCase();
let paddedHexCode = ("0000" + hexCharCode).slice(-4);
return "\\u" + paddedHexCode;
}
let nonAsciiCharacters = /[^\u0000-\u007F]/g;
export function escapeNonAsciiCharacters(s: string): string {
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
@ -1768,4 +1768,7 @@ module ts {
}
}
export function getLocalSymbolForExportDefault(symbol: Symbol) {
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
}
}

View file

@ -2405,8 +2405,11 @@ module ts {
}
// If this is the default export, get the name of the declaration if it exists
if (displayName === "default" && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) && symbol.valueDeclaration.localSymbol && symbol.valueDeclaration.localSymbol.name) {
displayName = symbol.valueDeclaration.localSymbol.name;
if (displayName === "default") {
let localSymbol = getLocalSymbolForExportDefault(symbol);
if (localSymbol && localSymbol.name) {
displayName = symbol.valueDeclaration.localSymbol.name;
}
}
let firstCharCode = displayName.charCodeAt(0);