Remove unnecessary diagnostics split on SourceFile.

This commit is contained in:
Cyrus Najmabadi committed 2015-02-05 13:38:11 -08:00
1 parent f20fbb9726
commit ea4e3de91c
14 files changed
+13 -78

No files matched your search

+2 -11
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];
}
+5 -1
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();
+2 -9
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[];
+2 -2
View File
@@ -1407,7 +1407,7 @@ module FourSlash {
var incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName);
Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined);
var incrementalSyntaxDiagnostics = ts.getSyntacticDiagnostics(incrementalSourceFile);
var incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics;
// Check syntactic structure
var snapshot = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName);
@@ -1415,7 +1415,7 @@ module FourSlash {
var referenceSourceFile = ts.createLanguageServiceSourceFile(
this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false);
var referenceSyntaxDiagnostics = ts.getSyntacticDiagnostics(referenceSourceFile);
var referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics;
Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics);
Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile);
-5
View File
@@ -64,7 +64,6 @@ module ts {
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getSyntacticDiagnostics(): Diagnostic[];
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
@@ -747,10 +746,6 @@ module ts {
private namedDeclarations: Declaration[];
public getSyntacticDiagnostics(): Diagnostic[]{
return getSyntacticDiagnostics(this);
}
public update(newText: string, textChangeRange: TextChangeRange): SourceFile {
return updateSourceFile(this, newText, textChangeRange);
}