Responded to CR feedback.

Conflicts:
	src/compiler/parser.ts
This commit is contained in:
Daniel Rosenwasser
2014-12-10 17:34:17 -08:00
parent 036209a89e
commit 94cce178dd
2 changed files with 18 additions and 15 deletions

View File

@@ -14,18 +14,6 @@ module ts {
return new (getNodeConstructor(kind))();
}
function isEvalOrArgumentsIdentifier(node: Node): boolean {
return node.kind === SyntaxKind.Identifier &&
(<Identifier>node).text &&
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
}
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
function isUseStrictPrologueDirective(node: Node): boolean {
Debug.assert(isPrologueDirective(node));
return (<Identifier>(<ExpressionStatement>node).expression).text === "use strict";
}
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
@@ -327,7 +315,9 @@ module ts {
sys.writeFile(fileName, data, writeByteOrderMark);
}
catch (e) {
if (onError) onError(e.message);
if (onError) {
onError(e.message);
}
}
}
@@ -433,6 +423,17 @@ module ts {
forEachChild(sourceFile, walk);
}
function isEvalOrArgumentsIdentifier(node: Node): boolean {
return node.kind === SyntaxKind.Identifier &&
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
}
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
function isUseStrictPrologueDirective(node: Node): boolean {
Debug.assert(isPrologueDirective(node));
return getTextOfNode((<ExpressionStatement>node).expression) === '"use strict"';
}
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile {
var parsingContext: ParsingContext;
var identifiers: Map<string> = {};

View File

@@ -90,7 +90,9 @@ module ts {
}
export function getSourceFileOfNode(node: Node): SourceFile {
while (node && node.kind !== SyntaxKind.SourceFile) node = node.parent;
while (node && node.kind !== SyntaxKind.SourceFile) {
node = node.parent;
}
return <SourceFile>node;
}
@@ -161,7 +163,7 @@ module ts {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
var start = getFullWidth(node) === 0 ? node.pos : skipTrivia(file.text, node.pos);
var start = getTokenPosOfNode(node, file);
var length = node.end - start;
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);