Skip to content

Commit 201a31c

Browse files
authored
Merge pull request quarkusio#47950 from stuartwdouglas/stuartwdouglas/kotlin-comp
Refresh deleted source file location
2 parents 478ff47 + 86c1182 commit 201a31c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ nb-configuration.xml
3939
.mvn/.develocity
4040
.mvn/.gradle-enterprise/
4141
.quarkus
42+
43+
.goosehints
44+
.goose

core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,18 @@ private void checkForClassFilesChangesInModule(DevModeContext.ModuleInfo module,
849849
.collect(Collectors.toSet());
850850

851851
for (Path classFilePath : classFilePaths) {
852-
final Path sourceFilePath = retrieveSourceFilePathForClassFile(classFilePath, moduleChangedSourceFiles,
853-
module, cuf, timestampSet);
854-
852+
Path sourceFilePath = retrieveSourceFilePathForClassFile(classFilePath, moduleChangedSourceFiles,
853+
module, cuf, timestampSet, false);
855854
if (sourceFilePath != null) {
855+
if (!sourceFilePath.toFile().exists()) {
856+
// We need to refresh this in case the source file has changed
857+
// This can happen if you rename a kotlin file, the same class will now be provided by a new file
858+
var updated = retrieveSourceFilePathForClassFile(classFilePath, moduleChangedSourceFiles,
859+
module, cuf, timestampSet, true);
860+
if (updated != null) {
861+
sourceFilePath = updated;
862+
}
863+
}
856864
if (!sourceFilePath.toFile().exists()) {
857865
// Source file has been deleted. Delete class and restart
858866
cleanUpClassFile(classFilePath, timestampSet);
@@ -888,9 +896,9 @@ private void checkForClassFilesChangesInModule(DevModeContext.ModuleInfo module,
888896

889897
private Path retrieveSourceFilePathForClassFile(Path classFilePath, List<Path> moduleChangedSourceFiles,
890898
DevModeContext.ModuleInfo module, Function<DevModeContext.ModuleInfo, DevModeContext.CompilationUnit> cuf,
891-
TimestampSet timestampSet) {
899+
TimestampSet timestampSet, boolean forceRefresh) {
892900
Path sourceFilePath = timestampSet.classFilePathToSourceFilePath.get(classFilePath);
893-
if (sourceFilePath == null || moduleChangedSourceFiles.contains(sourceFilePath)) {
901+
if (sourceFilePath == null || moduleChangedSourceFiles.contains(sourceFilePath) || forceRefresh) {
894902
sourceFilePath = compiler.findSourcePath(classFilePath, cuf.apply(module).getSourcePaths(),
895903
cuf.apply(module).getClassesPath());
896904
}

0 commit comments

Comments
 (0)