mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Remove unnecessary diagnostics split on SourceFile.
This commit is contained in:
parent
f20fbb9726
commit
ea4e3de91c
@ -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];
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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[];
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1407,7 +1407,6 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
@ -1473,7 +1472,6 @@ declare module "typescript" {
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
|
||||
@ -4493,12 +4493,6 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
@ -4755,10 +4749,6 @@ declare module "typescript" {
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
|
||||
@ -1439,7 +1439,6 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
@ -1505,7 +1504,6 @@ declare module "typescript" {
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
|
||||
@ -4640,12 +4640,6 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
@ -4902,10 +4896,6 @@ declare module "typescript" {
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
|
||||
@ -1440,7 +1440,6 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
@ -1506,7 +1505,6 @@ declare module "typescript" {
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
|
||||
@ -4592,12 +4592,6 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
@ -4854,10 +4848,6 @@ declare module "typescript" {
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
|
||||
@ -1477,7 +1477,6 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
@ -1543,7 +1542,6 @@ declare module "typescript" {
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
|
||||
@ -4766,12 +4766,6 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
@ -5028,10 +5022,6 @@ declare module "typescript" {
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
|
||||
@ -24,8 +24,8 @@ module ts {
|
||||
}
|
||||
|
||||
function assertSameDiagnostics(file1: SourceFile, file2: SourceFile) {
|
||||
var diagnostics1 = getSyntacticDiagnostics(file1);
|
||||
var diagnostics2 = getSyntacticDiagnostics(file2);
|
||||
var diagnostics1 = file1.parseDiagnostics;
|
||||
var diagnostics2 = file2.parseDiagnostics;
|
||||
|
||||
assert.equal(diagnostics1.length, diagnostics2.length, "diagnostics1.length !== diagnostics2.length");
|
||||
for (var i = 0, n = diagnostics1.length; i < n; i++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user