Skip to content

Commit e015b17

Browse files
Merge branch 'master' into cancellableDiagnostics
Conflicts: src/compiler/checker.ts src/compiler/program.ts src/compiler/types.ts src/services/services.ts
2 parents 1a96a14 + 3a9bc99 commit e015b17

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ namespace ts {
159159
}
160160
};
161161

162+
let subtypeRelation: Map<RelationComparisonResult> = {};
163+
let assignableRelation: Map<RelationComparisonResult> = {};
164+
let identityRelation: Map<RelationComparisonResult> = {};
165+
166+
initializeTypeChecker();
167+
168+
return checker;
169+
162170
function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationTokenObject) {
163171
// Ensure we have all the type information in place for this file so that all the
164172
// emitter questions of this resolver will return the right information.
@@ -4221,10 +4229,6 @@ namespace ts {
42214229

42224230
// TYPE CHECKING
42234231

4224-
let subtypeRelation: Map<RelationComparisonResult> = {};
4225-
let assignableRelation: Map<RelationComparisonResult> = {};
4226-
let identityRelation: Map<RelationComparisonResult> = {};
4227-
42284232
function isTypeIdenticalTo(source: Type, target: Type): boolean {
42294233
return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined);
42304234
}
@@ -13641,9 +13645,5 @@ namespace ts {
1364113645
return true;
1364213646
}
1364313647
}
13644-
13645-
initializeTypeChecker();
13646-
13647-
return checker;
1364813648
}
1364913649
}

src/compiler/program.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ namespace ts {
105105
}
106106

107107
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[] {
108-
let diagnostics = program.getSyntacticDiagnostics(sourceFile, cancellationToken).concat(
109-
program.getGlobalDiagnostics(cancellationToken)).concat(
108+
let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
109+
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
110+
program.getGlobalDiagnostics(cancellationToken),
110111
program.getSemanticDiagnostics(sourceFile, cancellationToken));
111112

112113
if (program.getCompilerOptions().declaration) {
@@ -179,10 +180,10 @@ namespace ts {
179180
getSourceFiles: () => files,
180181
getCompilerOptions: () => options,
181182
getSyntacticDiagnostics,
183+
getOptionsDiagnostics,
182184
getGlobalDiagnostics,
183185
getSemanticDiagnostics,
184186
getDeclarationDiagnostics,
185-
getCompilerOptionsDiagnostics,
186187
getTypeChecker,
187188
getClassifiableNames,
188189
getDiagnosticsProducingTypeChecker,
@@ -344,19 +345,15 @@ namespace ts {
344345
});
345346
}
346347

347-
function getCompilerOptionsDiagnostics(): Diagnostic[] {
348+
function getOptionsDiagnostics(): Diagnostic[] {
348349
let allDiagnostics: Diagnostic[] = [];
349350
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
350351
return sortAndDeduplicateDiagnostics(allDiagnostics);
351352
}
352353

353354
function getGlobalDiagnostics(): Diagnostic[] {
354-
let typeChecker = getDiagnosticsProducingTypeChecker();
355-
356355
let allDiagnostics: Diagnostic[] = [];
357-
addRange(allDiagnostics, typeChecker.getGlobalDiagnostics());
358-
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
359-
356+
addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics());
360357
return sortAndDeduplicateDiagnostics(allDiagnostics);
361358
}
362359

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,11 @@ namespace ts {
12121212
*/
12131213
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationTokenObject): EmitResult;
12141214

1215-
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[];
1215+
getOptionsDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[];
12161216
getGlobalDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[];
1217+
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[];
12171218
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[];
12181219
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationTokenObject): Diagnostic[];
1219-
/* @internal */ getCompilerOptionsDiagnostics(cancellationToken?: CancellationTokenObject): Diagnostic[];
12201220

12211221
/**
12221222
* Gets a type checker that can be used to semantically analyze source fils in the program.

src/services/services.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,9 @@ namespace ts {
973973

974974
getSyntacticDiagnostics(fileName: string): Diagnostic[];
975975
getSemanticDiagnostics(fileName: string): Diagnostic[];
976+
977+
// TODO: Rename this to getProgramDiagnostics to better indicate that these are any
978+
// diagnostics present for the program level, and not just 'options' diagnostics.
976979
getCompilerOptionsDiagnostics(): Diagnostic[];
977980

978981
/**
@@ -1790,8 +1793,8 @@ namespace ts {
17901793

17911794
var program = createProgram([inputFileName], options, compilerHost);
17921795

1793-
addRange(/*to*/ diagnostics, /*from*/ sourceFile.parseDiagnostics);
1794-
addRange(/*to*/ diagnostics, /*from*/ program.getCompilerOptionsDiagnostics());
1796+
addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
1797+
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
17951798

17961799
// Emit
17971800
program.emit();
@@ -2770,7 +2773,8 @@ namespace ts {
27702773

27712774
function getCompilerOptionsDiagnostics() {
27722775
synchronizeHostData();
2773-
return program.getGlobalDiagnostics(cancellationToken);
2776+
return program.getOptionsDiagnostics(cancellationToken).concat(
2777+
program.getGlobalDiagnostics(cancellationToken));
27742778
}
27752779

27762780
/// Completion

tests/perftsc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (perftest.hasLogIOFlag()) {
1010
var content = perftest.readFile(s);
1111
return content !== undefined ? ts.createSourceFile(s, content, v) : undefined;
1212
},
13-
getDefaultLibFilename: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
13+
getDefaultLibFileName: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
1414
writeFile: (f: string, content: string) => { throw new Error("Unexpected operation: writeFile"); },
1515
getCurrentDirectory: () => perftest.getCurrentDirectory(),
1616
getCanonicalFileName: (f: string) => ts.sys.useCaseSensitiveFileNames ? f : f.toLowerCase(),
@@ -19,8 +19,8 @@ if (perftest.hasLogIOFlag()) {
1919
};
2020

2121
var commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag());
22-
var program = ts.createProgram(commandLine.filenames, commandLine.options, compilerHost);
23-
var fileNames = program.getSourceFiles().map(f => f.filename);
22+
var program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost);
23+
var fileNames = program.getSourceFiles().map(f => f.fileName);
2424
perftest.writeIOLog(fileNames);
2525
}
2626
else {

0 commit comments

Comments
 (0)