Merge pull request #7311 from Microsoft/issue7310

Fix JS parsing perf issue (#7310)
This commit is contained in:
Bill Ticehurst 2016-03-01 10:57:36 -08:00
commit 619ed2b956
3 changed files with 7 additions and 2 deletions

View File

@ -430,7 +430,7 @@ namespace ts {
JavaScriptFile = 1 << 5,
// Context flags set directly by the parser.
ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await,
ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await | JavaScriptFile,
// Exclude these flags when parsing a Type
TypeExcludesFlags = Yield | Await,

View File

@ -285,6 +285,10 @@ namespace Utils {
// data we don't care about in the dump. We only care what the parser set directly
// on the ast.
let value = n.parserContextFlags & ts.ParserContextFlags.ParserGeneratedFlags;
// Remove the JavaScriptFile flag, as this is just noise for JSDocParser and Test262 tests
// (which are the only tests that use this function).
value = value & ~ts.ParserContextFlags.JavaScriptFile;
if (value) {
o[propertyName] = getParserContextFlagName(value);
}

View File

@ -11,6 +11,7 @@ module ts {
assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0);
let result = Utils.sourceFileToJSON(typeAndDiagnostics.jsDocTypeExpression.type);
assert.equal(result, expected);
}
@ -998,7 +999,7 @@ module ts {
? JSON.parse(Utils.sourceFileToJSON(v))
: v;
}, 4);
if (result !== expected) {
// Turn on a human-readable diff
if (typeof require !== 'undefined') {