mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Hide the diagnostic producing methods from TypeChecker.
Instead, consumers should get these diagnostics through the Program instance.
This commit is contained in:
@@ -98,9 +98,11 @@ module ts {
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getCompilerHost: () => host,
|
||||
getDiagnostics: getDiagnostics,
|
||||
getGlobalDiagnostics: getGlobalDiagnostics,
|
||||
getDeclarationDiagnostics: getDeclarationDiagnostics,
|
||||
getDiagnostics,
|
||||
getGlobalDiagnostics,
|
||||
getTypeCheckerDiagnostics,
|
||||
getTypeCheckerGlobalDiagnostics,
|
||||
getDeclarationDiagnostics,
|
||||
getTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
emitFiles: invokeEmitter,
|
||||
@@ -115,7 +117,7 @@ module ts {
|
||||
|
||||
function isEmitBlocked(sourceFile?: SourceFile): boolean {
|
||||
if (options.noEmitOnError) {
|
||||
return getDiagnostics(sourceFile).length !== 0 || getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile).length !== 0;
|
||||
return getDiagnostics(sourceFile).length !== 0 || getTypeCheckerDiagnostics(sourceFile).length !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -151,6 +153,14 @@ module ts {
|
||||
return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined;
|
||||
}
|
||||
|
||||
function getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
function getTypeCheckerGlobalDiagnostics(): Diagnostic[] {
|
||||
return getDiagnosticsProducingTypeChecker().getGlobalDiagnostics();
|
||||
}
|
||||
|
||||
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return sourceFile ? filter(errors, e => e.file === sourceFile) : errors;
|
||||
}
|
||||
|
||||
@@ -931,6 +931,10 @@ module ts {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
|
||||
// These will merge with the below diagnostics function in a followup checkin.
|
||||
getTypeCheckerDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getTypeCheckerGlobalDiagnostics(): Diagnostic[];
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
@@ -997,8 +1001,6 @@ module ts {
|
||||
|
||||
export interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -1028,6 +1030,10 @@ module ts {
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
|
||||
@@ -2184,13 +2184,12 @@ module ts {
|
||||
|
||||
fileName = normalizeSlashes(fileName)
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var checker = getDiagnosticsProducingTypeChecker();
|
||||
var targetSourceFile = getValidSourceFile(fileName);
|
||||
|
||||
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
|
||||
// Therefore only get diagnostics for given file.
|
||||
|
||||
var allDiagnostics = checker.getDiagnostics(targetSourceFile);
|
||||
var allDiagnostics = program.getTypeCheckerDiagnostics(targetSourceFile);
|
||||
if (compilerOptions.declaration) {
|
||||
// If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface
|
||||
allDiagnostics = allDiagnostics.concat(program.getDeclarationDiagnostics(targetSourceFile));
|
||||
|
||||
Reference in New Issue
Block a user