From 617fd2c5c9e56c59ca7b5c83178bd3264c27098a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 20 Nov 2014 14:18:04 -0800 Subject: [PATCH] Remove SourceFileInternal. --- src/compiler/parser.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 88c823fa977..2f96e4f734d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -814,12 +814,6 @@ module ts { return false; } - interface SourceFileInternal extends SourceFile { - // All diagnostics for the source file. Should not be accessed directly. Lazily created - // when getSyntacticDiagnostics is called. - _syntacticDiagnostics: Diagnostic[]; - } - function modifierToFlag(token: SyntaxKind): NodeFlags { switch (token) { case SyntaxKind.StaticKeyword: return NodeFlags.Static; @@ -833,7 +827,7 @@ module ts { } export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen: boolean = false): SourceFile { - var file: SourceFileInternal; + var file: SourceFile; var scanner: Scanner; var token: SyntaxKind; var parsingContext: ParsingContext; @@ -3439,22 +3433,23 @@ module ts { : undefined); } + var syntacticDiagnostics: Diagnostic[]; function getSyntacticDiagnostics() { - if (file._syntacticDiagnostics === undefined) { + if (syntacticDiagnostics === undefined) { if (file.parseDiagnostics.length > 0) { // Don't bother doing any grammar checks if there are already parser errors. // Otherwise we may end up with too many cascading errors. - file._syntacticDiagnostics = file.parseDiagnostics; + syntacticDiagnostics = file.parseDiagnostics; } else { // No parser errors were reported. Perform our stricter grammar checks. - file._syntacticDiagnostics = file.grammarDiagnostics; + syntacticDiagnostics = file.grammarDiagnostics; checkGrammar(sourceText, languageVersion, file); } } - Debug.assert(file._syntacticDiagnostics !== undefined); - return file._syntacticDiagnostics + Debug.assert(syntacticDiagnostics !== undefined); + return syntacticDiagnostics; } scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText, scanError, onComment); @@ -3462,7 +3457,7 @@ module ts { if (fileExtensionIs(filename, ".d.ts")) { rootNodeFlags = NodeFlags.DeclarationFile; } - file = createRootNode(SyntaxKind.SourceFile, 0, sourceText.length, rootNodeFlags); + file = createRootNode(SyntaxKind.SourceFile, 0, sourceText.length, rootNodeFlags); file.filename = normalizePath(filename); file.text = sourceText; file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; @@ -3524,7 +3519,7 @@ module ts { return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment; } - function checkGrammar(sourceText: string, languageVersion: ScriptTarget, file: SourceFileInternal) { + function checkGrammar(sourceText: string, languageVersion: ScriptTarget, file: SourceFile) { var grammarDiagnostics = file.grammarDiagnostics; // Create a scanner so we can find the start of tokens to report errors on.