MCPcopy Index your code
hub / github.com/nodejs/node / getNextAffectedFile

Function getNextAffectedFile

test/fixtures/snapshot/typescript.js:120238–120291  ·  view source on GitHub ↗

* This function returns the next affected file to be processed. * Note that until doneAffected is called it would keep reporting same result * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check

(state, cancellationToken, computeHash, host)

Source from the content-addressed store, hash-verified

120236 * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
120237 */
120238 function getNextAffectedFile(state, cancellationToken, computeHash, host) {
120239 var _a;
120240 while (true) {
120241 var affectedFiles = state.affectedFiles;
120242 if (affectedFiles) {
120243 var seenAffectedFiles = state.seenAffectedFiles;
120244 var affectedFilesIndex = state.affectedFilesIndex; // TODO: GH#18217
120245 while (affectedFilesIndex < affectedFiles.length) {
120246 var affectedFile = affectedFiles[affectedFilesIndex];
120247 if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
120248 // Set the next affected file as seen and remove the cached semantic diagnostics
120249 state.affectedFilesIndex = affectedFilesIndex;
120250 handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
120251 return affectedFile;
120252 }
120253 affectedFilesIndex++;
120254 }
120255 // Remove the changed file from the change set
120256 state.changedFilesSet.delete(state.currentChangedFilePath);
120257 state.currentChangedFilePath = undefined;
120258 // Commit the changes in file signature
120259 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
120260 state.currentAffectedFilesSignatures.clear();
120261 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120262 (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
120263 state.affectedFiles = undefined;
120264 }
120265 // Get next changed file
120266 var nextKey = state.changedFilesSet.keys().next();
120267 if (nextKey.done) {
120268 // Done
120269 return undefined;
120270 }
120271 // With --out or --outFile all outputs go into single file
120272 // so operations are performed directly on program, return program
120273 var program = ts.Debug.checkDefined(state.program);
120274 var compilerOptions = program.getCompilerOptions();
120275 if (ts.outFile(compilerOptions)) {
120276 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
120277 return program;
120278 }
120279 // Get next batch of affected files
120280 if (!state.currentAffectedFilesSignatures)
120281 state.currentAffectedFilesSignatures = new ts.Map();
120282 if (state.exportedModulesMap) {
120283 state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap());
120284 }
120285 state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
120286 state.currentChangedFilePath = nextKey.value;
120287 state.affectedFilesIndex = 0;
120288 if (!state.seenAffectedFiles)
120289 state.seenAffectedFiles = new ts.Set();
120290 }
120291 }
120292 function clearAffectedFilesPendingEmit(state) {
120293 state.affectedFilesPendingEmit = undefined;
120294 state.affectedFilesPendingEmitKind = undefined;

Callers 2

emitNextAffectedFileFunction · 0.85

Calls 7

assertMethod · 0.80
hasMethod · 0.65
deleteMethod · 0.65
clearMethod · 0.65
nextMethod · 0.65
keysMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…