MCPcopy Create free account
hub / github.com/nodejs/node / updateImportsWorker

Function updateImportsWorker

test/fixtures/snapshot/typescript.js:139631–139644  ·  view source on GitHub ↗
(sourceFile, changeTracker, updateRef, updateImport)

Source from the content-addressed store, hash-verified

139629 }
139630 }
139631 function updateImportsWorker(sourceFile, changeTracker, updateRef, updateImport) {
139632 for (var _i = 0, _a = sourceFile.referencedFiles || ts.emptyArray; _i < _a.length; _i++) { // TODO: GH#26162
139633 var ref = _a[_i];
139634 var updated = updateRef(ref.fileName);
139635 if (updated !== undefined && updated !== sourceFile.text.slice(ref.pos, ref.end))
139636 changeTracker.replaceRangeWithText(sourceFile, ref, updated);
139637 }
139638 for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) {
139639 var importStringLiteral = _c[_b];
139640 var updated = updateImport(importStringLiteral);
139641 if (updated !== undefined && updated !== importStringLiteral.text)
139642 changeTracker.replaceRangeWithText(sourceFile, createStringRange(importStringLiteral, sourceFile), updated);
139643 }
139644 }
139645 function createStringRange(node, sourceFile) {
139646 return ts.createRange(node.getStart(sourceFile) + 1, node.end - 1);
139647 }

Callers 1

_loop_6Function · 0.85

Calls 3

updateImportFunction · 0.85
createStringRangeFunction · 0.85
sliceMethod · 0.65

Tested by

no test coverage detected