@@ -1183,165 +1183,4 @@ namespace ts {
1183
1183
return Debug . assertDefined ( state . program ) ;
1184
1184
}
1185
1185
}
1186
- }
1187
-
1188
- namespace ts {
1189
- export type AffectedFileResult < T > = { result : T ; affected : SourceFile | Program ; } | undefined ;
1190
-
1191
- export interface BuilderProgramHost {
1192
- /**
1193
- * return true if file names are treated with case sensitivity
1194
- */
1195
- useCaseSensitiveFileNames ( ) : boolean ;
1196
- /**
1197
- * If provided this would be used this hash instead of actual file shape text for detecting changes
1198
- */
1199
- createHash ?: ( data : string ) => string ;
1200
- /**
1201
- * When emit or emitNextAffectedFile are called without writeFile,
1202
- * this callback if present would be used to write files
1203
- */
1204
- writeFile ?: WriteFileCallback ;
1205
- }
1206
-
1207
- /**
1208
- * Builder to manage the program state changes
1209
- */
1210
- export interface BuilderProgram {
1211
- /*@internal */
1212
- getState ( ) : ReusableBuilderProgramState ;
1213
- /*@internal */
1214
- backupState ( ) : void ;
1215
- /*@internal */
1216
- restoreState ( ) : void ;
1217
- /**
1218
- * Returns current program
1219
- */
1220
- getProgram ( ) : Program ;
1221
- /**
1222
- * Returns current program that could be undefined if the program was released
1223
- */
1224
- /*@internal */
1225
- getProgramOrUndefined ( ) : Program | undefined ;
1226
- /**
1227
- * Releases reference to the program, making all the other operations that need program to fail.
1228
- */
1229
- /*@internal */
1230
- releaseProgram ( ) : void ;
1231
- /**
1232
- * Get compiler options of the program
1233
- */
1234
- getCompilerOptions ( ) : CompilerOptions ;
1235
- /**
1236
- * Get the source file in the program with file name
1237
- */
1238
- getSourceFile ( fileName : string ) : SourceFile | undefined ;
1239
- /**
1240
- * Get a list of files in the program
1241
- */
1242
- getSourceFiles ( ) : readonly SourceFile [ ] ;
1243
- /**
1244
- * Get the diagnostics for compiler options
1245
- */
1246
- getOptionsDiagnostics ( cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
1247
- /**
1248
- * Get the diagnostics that dont belong to any file
1249
- */
1250
- getGlobalDiagnostics ( cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
1251
- /**
1252
- * Get the diagnostics from config file parsing
1253
- */
1254
- getConfigFileParsingDiagnostics ( ) : readonly Diagnostic [ ] ;
1255
- /**
1256
- * Get the syntax diagnostics, for all source files if source file is not supplied
1257
- */
1258
- getSyntacticDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
1259
- /**
1260
- * Get the declaration diagnostics, for all source files if source file is not supplied
1261
- */
1262
- getDeclarationDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly DiagnosticWithLocation [ ] ;
1263
- /**
1264
- * Get all the dependencies of the file
1265
- */
1266
- getAllDependencies ( sourceFile : SourceFile ) : readonly string [ ] ;
1267
-
1268
- /**
1269
- * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program
1270
- * The semantic diagnostics are cached and managed here
1271
- * Note that it is assumed that when asked about semantic diagnostics through this API,
1272
- * the file has been taken out of affected files so it is safe to use cache or get from program and cache the diagnostics
1273
- * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided,
1274
- * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics
1275
- */
1276
- getSemanticDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
1277
- /**
1278
- * Emits the JavaScript and declaration files.
1279
- * When targetSource file is specified, emits the files corresponding to that source file,
1280
- * otherwise for the whole program.
1281
- * In case of EmitAndSemanticDiagnosticsBuilderProgram, when targetSourceFile is specified,
1282
- * it is assumed that that file is handled from affected file list. If targetSourceFile is not specified,
1283
- * it will only emit all the affected files instead of whole program
1284
- *
1285
- * The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
1286
- * in that order would be used to write the files
1287
- */
1288
- emit ( targetSourceFile ?: SourceFile , writeFile ?: WriteFileCallback , cancellationToken ?: CancellationToken , emitOnlyDtsFiles ?: boolean , customTransformers ?: CustomTransformers ) : EmitResult ;
1289
- /**
1290
- * Get the current directory of the program
1291
- */
1292
- getCurrentDirectory ( ) : string ;
1293
- }
1294
-
1295
- /**
1296
- * The builder that caches the semantic diagnostics for the program and handles the changed files and affected files
1297
- */
1298
- export interface SemanticDiagnosticsBuilderProgram extends BuilderProgram {
1299
- /**
1300
- * Gets the semantic diagnostics from the program for the next affected file and caches it
1301
- * Returns undefined if the iteration is complete
1302
- */
1303
- getSemanticDiagnosticsOfNextAffectedFile ( cancellationToken ?: CancellationToken , ignoreSourceFile ?: ( sourceFile : SourceFile ) => boolean ) : AffectedFileResult < readonly Diagnostic [ ] > ;
1304
- }
1305
-
1306
- /**
1307
- * The builder that can handle the changes in program and iterate through changed file to emit the files
1308
- * The semantic diagnostics are cached per file and managed by clearing for the changed/affected files
1309
- */
1310
- export interface EmitAndSemanticDiagnosticsBuilderProgram extends SemanticDiagnosticsBuilderProgram {
1311
- /**
1312
- * Emits the next affected file's emit result (EmitResult and sourceFiles emitted) or returns undefined if iteration is complete
1313
- * The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
1314
- * in that order would be used to write the files
1315
- */
1316
- emitNextAffectedFile ( writeFile ?: WriteFileCallback , cancellationToken ?: CancellationToken , emitOnlyDtsFiles ?: boolean , customTransformers ?: CustomTransformers ) : AffectedFileResult < EmitResult > ;
1317
- }
1318
-
1319
- /**
1320
- * Create the builder to manage semantic diagnostics and cache them
1321
- */
1322
- export function createSemanticDiagnosticsBuilderProgram ( newProgram : Program , host : BuilderProgramHost , oldProgram ?: SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : SemanticDiagnosticsBuilderProgram ;
1323
- export function createSemanticDiagnosticsBuilderProgram ( rootNames : readonly string [ ] | undefined , options : CompilerOptions | undefined , host ?: CompilerHost , oldProgram ?: SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : SemanticDiagnosticsBuilderProgram ;
1324
- export function createSemanticDiagnosticsBuilderProgram ( newProgramOrRootNames : Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | CompilerOptions | undefined , oldProgramOrHost ?: CompilerHost | SemanticDiagnosticsBuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly Diagnostic [ ] | SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) {
1325
- return createBuilderProgram ( BuilderProgramKind . SemanticDiagnosticsBuilderProgram , getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ) ;
1326
- }
1327
-
1328
- /**
1329
- * Create the builder that can handle the changes in program and iterate through changed files
1330
- * to emit the those files and manage semantic diagnostics cache as well
1331
- */
1332
- export function createEmitAndSemanticDiagnosticsBuilderProgram ( newProgram : Program , host : BuilderProgramHost , oldProgram ?: EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : EmitAndSemanticDiagnosticsBuilderProgram ;
1333
- export function createEmitAndSemanticDiagnosticsBuilderProgram ( rootNames : readonly string [ ] | undefined , options : CompilerOptions | undefined , host ?: CompilerHost , oldProgram ?: EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : EmitAndSemanticDiagnosticsBuilderProgram ;
1334
- export function createEmitAndSemanticDiagnosticsBuilderProgram ( newProgramOrRootNames : Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | CompilerOptions | undefined , oldProgramOrHost ?: CompilerHost | EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly Diagnostic [ ] | EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) {
1335
- return createBuilderProgram ( BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ) ;
1336
- }
1337
-
1338
- /**
1339
- * Creates a builder thats just abstraction over program and can be used with watch
1340
- */
1341
- export function createAbstractBuilder ( newProgram : Program , host : BuilderProgramHost , oldProgram ?: BuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : BuilderProgram ;
1342
- export function createAbstractBuilder ( rootNames : readonly string [ ] | undefined , options : CompilerOptions | undefined , host ?: CompilerHost , oldProgram ?: BuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : BuilderProgram ;
1343
- export function createAbstractBuilder ( newProgramOrRootNames : Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | CompilerOptions | undefined , oldProgramOrHost ?: CompilerHost | BuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly Diagnostic [ ] | BuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : BuilderProgram {
1344
- const { newProgram, configFileParsingDiagnostics : newConfigFileParsingDiagnostics } = getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ;
1345
- return createRedirectedBuilderProgram ( { program : newProgram , compilerOptions : newProgram . getCompilerOptions ( ) } , newConfigFileParsingDiagnostics ) ;
1346
- }
1347
- }
1186
+ }
0 commit comments