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

Function getPathUpdater

test/fixtures/snapshot/typescript.js:139447–139462  ·  view source on GitHub ↗
(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper)

Source from the content-addressed store, hash-verified

139445 ts.getEditsForFileRename = getEditsForFileRename;
139446 // exported for tests
139447 function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper) {
139448 var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath);
139449 return function (path) {
139450 var originalPath = sourceMapper && sourceMapper.tryGetSourcePosition({ fileName: path, pos: 0 });
139451 var updatedPath = getUpdatedPath(originalPath ? originalPath.fileName : path);
139452 return originalPath
139453 ? updatedPath === undefined ? undefined : makeCorrespondingRelativeChange(originalPath.fileName, updatedPath, path, getCanonicalFileName)
139454 : updatedPath;
139455 };
139456 function getUpdatedPath(pathToUpdate) {
139457 if (getCanonicalFileName(pathToUpdate) === canonicalOldPath)
139458 return newFileOrDirPath;
139459 var suffix = ts.tryRemoveDirectoryPrefix(pathToUpdate, canonicalOldPath, getCanonicalFileName);
139460 return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix;
139461 }
139462 }
139463 ts.getPathUpdater = getPathUpdater;
139464 // Relative path from a0 to b0 should be same as relative path from a1 to b1. Returns b1.
139465 function makeCorrespondingRelativeChange(a0, b0, a1, getCanonicalFileName) {

Callers 1

getEditsForFileRenameFunction · 0.85

Calls 3

getCanonicalFileNameFunction · 0.85
getUpdatedPathFunction · 0.85

Tested by

no test coverage detected