@@ -18,18 +18,12 @@ namespace ts {
18
18
text : string ;
19
19
}
20
20
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 */
28
22
export interface Builder {
29
23
/**
30
- * This is the callback when file infos in the builder are updated
24
+ * Call this to feed new program
31
25
*/
32
- onProgramUpdateGraph ( program : Program , hasInvalidatedResolution : HasInvalidatedResolution ) : void ;
26
+ updateProgram ( newProgram : Program ) : void ;
33
27
getFilesAffectedBy ( program : Program , path : Path ) : string [ ] ;
34
28
emitFile ( program : Program , path : Path ) : EmitOutput ;
35
29
@@ -97,6 +91,7 @@ namespace ts {
97
91
signature : string ;
98
92
}
99
93
94
+ /* @internal */
100
95
export function createBuilder (
101
96
getCanonicalFileName : ( fileName : string ) => string ,
102
97
getEmitOutput : ( program : Program , sourceFile : SourceFile , emitOnlyDtsFiles : boolean , isDetailed : boolean ) => EmitOutput | EmitOutputDetailed ,
@@ -110,15 +105,15 @@ namespace ts {
110
105
const changedFileNames = createMap < string > ( ) ;
111
106
let emitHandler : EmitHandler ;
112
107
return {
113
- onProgramUpdateGraph ,
108
+ updateProgram ,
114
109
getFilesAffectedBy,
115
110
emitFile,
116
111
emitChangedFiles,
117
112
getSemanticDiagnostics,
118
113
clear
119
114
} ;
120
115
121
- function createProgramGraph ( program : Program , hasInvalidatedResolution : HasInvalidatedResolution ) {
116
+ function createProgramGraph ( program : Program ) {
122
117
const currentIsModuleEmit = program . getCompilerOptions ( ) . module !== ModuleKind . None ;
123
118
if ( isModuleEmit !== currentIsModuleEmit ) {
124
119
isModuleEmit = currentIsModuleEmit ;
@@ -135,7 +130,7 @@ namespace ts {
135
130
// Remove existing file info
136
131
onDeleteValue : removeExistingFileInfo ,
137
132
// 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 )
139
134
}
140
135
) ;
141
136
}
@@ -157,27 +152,27 @@ namespace ts {
157
152
emitHandler . onRemoveSourceFile ( path ) ;
158
153
}
159
154
160
- function updateExistingFileInfo ( program : Program , existingInfo : FileInfo , sourceFile : SourceFile , hasInvalidatedResolution : HasInvalidatedResolution ) {
155
+ function updateExistingFileInfo ( program : Program , existingInfo : FileInfo , sourceFile : SourceFile ) {
161
156
if ( existingInfo . version !== sourceFile . version ) {
162
157
registerChangedFile ( sourceFile . path , sourceFile . fileName ) ;
163
158
existingInfo . version = sourceFile . version ;
164
159
emitHandler . onUpdateSourceFile ( program , sourceFile ) ;
165
160
}
166
- else if ( hasInvalidatedResolution ( sourceFile . path ) &&
161
+ else if ( program . hasInvalidatedResolution ( sourceFile . path ) &&
167
162
emitHandler . onUpdateSourceFileWithSameVersion ( program , sourceFile ) ) {
168
163
registerChangedFile ( sourceFile . path , sourceFile . fileName ) ;
169
164
}
170
165
}
171
166
172
167
function ensureProgramGraph ( program : Program ) {
173
168
if ( ! emitHandler ) {
174
- createProgramGraph ( program , returnFalse ) ;
169
+ createProgramGraph ( program ) ;
175
170
}
176
171
}
177
172
178
- function onProgramUpdateGraph ( program : Program , hasInvalidatedResolution : HasInvalidatedResolution ) {
173
+ function updateProgram ( newProgram : Program ) {
179
174
if ( emitHandler ) {
180
- createProgramGraph ( program , hasInvalidatedResolution ) ;
175
+ createProgramGraph ( newProgram ) ;
181
176
}
182
177
}
183
178
0 commit comments