Remove unnecessary diagnostics split on SourceFile.

This commit is contained in:
Cyrus Najmabadi
2015-02-05 13:38:11 -08:00
parent f20fbb9726
commit ea4e3de91c
14 changed files with 13 additions and 78 deletions

View File

@@ -357,14 +357,6 @@ module ts {
forEachChild(sourceFile, walk);
}
export function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[] {
if (!sourceFile.syntacticDiagnostics) {
sourceFile.syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics);
}
return sourceFile.syntacticDiagnostics;
}
function moveElementEntirelyPastChangeRange(element: IncrementalElement, delta: number) {
if (element.length) {
visitArray(<IncrementalNodeArray>element);
@@ -880,7 +872,6 @@ module ts {
sourceFile.end = sourceText.length;
sourceFile.text = sourceText;
sourceFile.referenceDiagnostics = [];
sourceFile.parseDiagnostics = [];
sourceFile.bindDiagnostics = [];
sourceFile.languageVersion = languageVersion;
@@ -4698,7 +4689,7 @@ module ts {
referencedFiles.push(fileReference);
}
if (diagnosticMessage) {
sourceFile.referenceDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage));
sourceFile.parseDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage));
}
}
else {
@@ -4706,7 +4697,7 @@ module ts {
var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment);
if (amdModuleNameMatchResult) {
if (amdModuleName) {
sourceFile.referenceDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments));
sourceFile.parseDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments));
}
amdModuleName = amdModuleNameMatchResult[2];
}

View File

@@ -225,13 +225,17 @@ module ts {
}
function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]{
return getDiagnosticsHelper(sourceFile, ts.getSyntacticDiagnostics);
return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile);
}
function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]{
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile);
}
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
return sourceFile.parseDiagnostics;
}
function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
var typeChecker = getDiagnosticsProducingTypeChecker();

View File

@@ -902,20 +902,13 @@ module ts {
/* @internal */ identifierCount: number;
/* @internal */ symbolCount: number;
// Diagnostics reported about the "///<reference" comments in the file.
/* @internal */ referenceDiagnostics: Diagnostic[];
// Parse errors refer specifically to things the parser could not understand at all (like
// missing tokens, or tokens it didn't know how to deal with).
// File level diagnostics reported by the parser (includes diagnostics about /// references
// as well as code diagnostics).
/* @internal */ parseDiagnostics: Diagnostic[];
// File level diagnostics reported by the binder.
/* @internal */ bindDiagnostics: Diagnostic[];
// Returns all syntactic diagnostics (i.e. the reference, parser and grammar diagnostics).
// This field should never be used directly, use getSyntacticDiagnostics function instead.
/* @internal */ syntacticDiagnostics: Diagnostic[];
// Stores a line map for the file.
// This field should never be used directly to obtain line map, use getLineMap function instead.
/* @internal */ lineMap: number[];