Skip to content

Commit 7f969e8

Browse files
committed
Making APIs as internal so that we can enable them after we have figured out final details
1 parent 898559b commit 7f969e8

File tree

6 files changed

+22
-378
lines changed

6 files changed

+22
-378
lines changed

src/compiler/builder.ts

+12-17
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@ namespace ts {
1818
text: string;
1919
}
2020

21-
export interface ChangedProgramFiles {
22-
/** Minimal set of list of files that require emit */
23-
readonly filesToEmit: ReadonlyArray<string>;
24-
/** File paths of source files changed/added/removed or affected by changed files */
25-
readonly changedFiles: ReadonlyArray<string>;
26-
}
27-
21+
/* @internal */
2822
export interface Builder {
2923
/**
30-
* This is the callback when file infos in the builder are updated
24+
* Call this to feed new program
3125
*/
32-
onProgramUpdateGraph(program: Program, hasInvalidatedResolution: HasInvalidatedResolution): void;
26+
updateProgram(newProgram: Program): void;
3327
getFilesAffectedBy(program: Program, path: Path): string[];
3428
emitFile(program: Program, path: Path): EmitOutput;
3529

@@ -97,6 +91,7 @@ namespace ts {
9791
signature: string;
9892
}
9993

94+
/* @internal */
10095
export function createBuilder(
10196
getCanonicalFileName: (fileName: string) => string,
10297
getEmitOutput: (program: Program, sourceFile: SourceFile, emitOnlyDtsFiles: boolean, isDetailed: boolean) => EmitOutput | EmitOutputDetailed,
@@ -110,15 +105,15 @@ namespace ts {
110105
const changedFileNames = createMap<string>();
111106
let emitHandler: EmitHandler;
112107
return {
113-
onProgramUpdateGraph,
108+
updateProgram,
114109
getFilesAffectedBy,
115110
emitFile,
116111
emitChangedFiles,
117112
getSemanticDiagnostics,
118113
clear
119114
};
120115

121-
function createProgramGraph(program: Program, hasInvalidatedResolution: HasInvalidatedResolution) {
116+
function createProgramGraph(program: Program) {
122117
const currentIsModuleEmit = program.getCompilerOptions().module !== ModuleKind.None;
123118
if (isModuleEmit !== currentIsModuleEmit) {
124119
isModuleEmit = currentIsModuleEmit;
@@ -135,7 +130,7 @@ namespace ts {
135130
// Remove existing file info
136131
onDeleteValue: removeExistingFileInfo,
137132
// We will update in place instead of deleting existing value and adding new one
138-
onExistingValue: (existingInfo, sourceFile) => updateExistingFileInfo(program, existingInfo, sourceFile, hasInvalidatedResolution)
133+
onExistingValue: (existingInfo, sourceFile) => updateExistingFileInfo(program, existingInfo, sourceFile)
139134
}
140135
);
141136
}
@@ -157,27 +152,27 @@ namespace ts {
157152
emitHandler.onRemoveSourceFile(path);
158153
}
159154

160-
function updateExistingFileInfo(program: Program, existingInfo: FileInfo, sourceFile: SourceFile, hasInvalidatedResolution: HasInvalidatedResolution) {
155+
function updateExistingFileInfo(program: Program, existingInfo: FileInfo, sourceFile: SourceFile) {
161156
if (existingInfo.version !== sourceFile.version) {
162157
registerChangedFile(sourceFile.path, sourceFile.fileName);
163158
existingInfo.version = sourceFile.version;
164159
emitHandler.onUpdateSourceFile(program, sourceFile);
165160
}
166-
else if (hasInvalidatedResolution(sourceFile.path) &&
161+
else if (program.hasInvalidatedResolution(sourceFile.path) &&
167162
emitHandler.onUpdateSourceFileWithSameVersion(program, sourceFile)) {
168163
registerChangedFile(sourceFile.path, sourceFile.fileName);
169164
}
170165
}
171166

172167
function ensureProgramGraph(program: Program) {
173168
if (!emitHandler) {
174-
createProgramGraph(program, returnFalse);
169+
createProgramGraph(program);
175170
}
176171
}
177172

178-
function onProgramUpdateGraph(program: Program, hasInvalidatedResolution: HasInvalidatedResolution) {
173+
function updateProgram(newProgram: Program) {
179174
if (emitHandler) {
180-
createProgramGraph(program, hasInvalidatedResolution);
175+
createProgramGraph(newProgram);
181176
}
182177
}
183178

src/compiler/program.ts

+1
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ namespace ts {
663663
getSourceFileFromReference,
664664
sourceFileToPackageName,
665665
redirectTargetsSet,
666+
hasInvalidatedResolution
666667
};
667668

668669
verifyCompilerOptions();

src/compiler/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,8 @@ namespace ts {
25252525
/* @internal */ sourceFileToPackageName: Map<string>;
25262526
/** Set of all source files that some other source file redirects to. */
25272527
/* @internal */ redirectTargetsSet: Map<true>;
2528+
/** Returns true when file in the program had invalidated resolution at the time of program creation. */
2529+
hasInvalidatedResolution: HasInvalidatedResolution;
25282530
}
25292531

25302532
/* @internal */

src/compiler/watch.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/// <reference path="builder.ts" />
33
/// <reference path="resolutionCache.ts"/>
44

5+
/* @internal */
56
namespace ts {
67
export type DiagnosticReporter = (diagnostic: Diagnostic) => void;
78
export type ParseConfigFile = (configFileName: string, optionsToExtend: CompilerOptions, system: DirectoryStructureHost, reportDiagnostic: DiagnosticReporter, reportWatchDiagnostic: DiagnosticReporter) => ParsedCommandLine;
@@ -341,7 +342,7 @@ namespace ts {
341342
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
342343
program = createProgram(rootFileNames, compilerOptions, compilerHost, program);
343344
resolutionCache.finishCachingPerDirectoryResolution();
344-
builder.onProgramUpdateGraph(program, hasInvalidatedResolution);
345+
builder.updateProgram(program);
345346

346347
// Update watches
347348
updateMissingFilePathsWatch(program, missingFilesMap || (missingFilesMap = createMap()), watchMissingFilePath);

0 commit comments

Comments
 (0)