Initial refactoring to support doing grammar checks as a separate pass of the tree.

Right now, this means hiding 'syntacticDiagnostics' behind a getter function that
only computes all the syntactic diagnostics (parser+grammar checks) lazily.

This will help incremental parsing out as we can reuse nodes that have grammar
errors in them, and we dont' have to even do grammar checks if this is not the
full-type-check type-checker.
This commit is contained in:
Cyrus Najmabadi
2014-11-18 15:51:55 -08:00
parent a9cf216d34
commit 00a49536fe
6 changed files with 96 additions and 57 deletions

View File

@@ -252,7 +252,7 @@ module ts.formatting {
rulesProvider: RulesProvider,
requestKind: FormattingRequestKind): TextChange[] {
var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.syntacticErrors, originalRange);
var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.getSyntacticDiagnostics(), originalRange);
// formatting context is used by rules provider
var formattingContext = new FormattingContext(sourceFile, requestKind);

View File

@@ -714,14 +714,18 @@ module ts {
class SourceFileObject extends NodeObject implements SourceFile {
public filename: string;
public text: string;
// These methods will have their implementation overridden with the implementation the
// compiler actually exports off of SourceFile.
public getLineAndCharacterFromPosition(position: number): { line: number; character: number } { return null; }
public getPositionFromLineAndCharacter(line: number, character: number): number { return -1; }
public getLineStarts(): number[] { return undefined; }
public getSyntacticDiagnostics(): Diagnostic[] { return undefined; }
public amdDependencies: string[];
public amdModuleName: string;
public referencedFiles: FileReference[];
public syntacticErrors: Diagnostic[];
public semanticErrors: Diagnostic[];
public semanticDiagnostics: Diagnostic[];
public hasNoDefaultLib: boolean;
public externalModuleIndicator: Node; // The first node that causes this file to be an external module
public nodeCount: number;