mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
getEditsForFileRename: Handle old file still being present
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
"../services/documentRegistry.ts",
|
||||
"../services/importTracker.ts",
|
||||
"../services/findAllReferences.ts",
|
||||
"../services/getEditsForFileRename.ts",
|
||||
"../services/goToDefinition.ts",
|
||||
"../services/jsDoc.ts",
|
||||
"../services/semver.ts",
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
"../services/documentRegistry.ts",
|
||||
"../services/importTracker.ts",
|
||||
"../services/findAllReferences.ts",
|
||||
"../services/getEditsForFileRename.ts",
|
||||
"../services/goToDefinition.ts",
|
||||
"../services/jsDoc.ts",
|
||||
"../services/semver.ts",
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
"../services/documentRegistry.ts",
|
||||
"../services/importTracker.ts",
|
||||
"../services/findAllReferences.ts",
|
||||
"../services/getEditsForFileRename.ts",
|
||||
"../services/goToDefinition.ts",
|
||||
"../services/jsDoc.ts",
|
||||
"../services/semver.ts",
|
||||
|
||||
@@ -31,23 +31,20 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getImportsToUpdate(program: Program, oldFilePath: string, host: LanguageServiceHost): ReadonlyArray<ToUpdate> {
|
||||
const checker = program.getTypeChecker();
|
||||
const result: ToUpdate[] = [];
|
||||
for (const sourceFile of program.getSourceFiles()) {
|
||||
for (const ref of sourceFile.referencedFiles) {
|
||||
if (!program.getSourceFileFromReference(sourceFile, ref) && resolveTripleslashReference(ref.fileName, sourceFile.fileName) === oldFilePath) {
|
||||
if (resolveTripleslashReference(ref.fileName, sourceFile.fileName) === oldFilePath) {
|
||||
result.push({ sourceFile, toUpdate: ref });
|
||||
}
|
||||
}
|
||||
|
||||
for (const importStringLiteral of sourceFile.imports) {
|
||||
// If it resolved to something already, ignore.
|
||||
if (checker.getSymbolAtLocation(importStringLiteral)) continue;
|
||||
|
||||
const resolved = host.resolveModuleNames
|
||||
? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName)
|
||||
: program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName);
|
||||
if (resolved && contains(resolved.failedLookupLocations, oldFilePath)) {
|
||||
// We may or may not have picked up on the file being renamed, so maybe successfully resolved to oldFilePath, or maybe that's in failedLookupLocations
|
||||
if (resolved && contains([resolved.resolvedModule && resolved.resolvedModule.resolvedFileName, ...resolved.failedLookupLocations], oldFilePath)) {
|
||||
result.push({ sourceFile, toUpdate: importStringLiteral });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"documentRegistry.ts",
|
||||
"importTracker.ts",
|
||||
"findAllReferences.ts",
|
||||
"getEditsForFileRename.ts",
|
||||
"goToDefinition.ts",
|
||||
"jsDoc.ts",
|
||||
"semver.ts",
|
||||
|
||||
Reference in New Issue
Block a user