mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 05:09:37 +07:00
[workspace model] fix loading newly added modules located deep under added directories (IDEA-253040)
If a directory was added, 'addedFileUrls' will contain only its direct children, so we need to explicitly add serializers for new modules mentioned in modules.xml files to 'affectedFileLoaders' list. GitOrigin-RevId: 61d2683b031374e0831a9e0a2c147a3ce7fc7b82
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5ecdcd4f91
commit
4c971bf289
8
java/java-tests/testData/reloading/addModuleFromSubDir/initial/.idea/modules.xml
generated
Normal file
8
java/java-tests/testData/reloading/addModuleFromSubDir/initial/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/foo.iml" filepath="$PROJECT_DIR$/foo.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="EMPTY_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
9
java/java-tests/testData/reloading/addModuleFromSubDir/update/.idea/modules.xml
generated
Normal file
9
java/java-tests/testData/reloading/addModuleFromSubDir/update/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/foo.iml" filepath="$PROJECT_DIR$/foo.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/bar/subDir/bar.iml" filepath="$PROJECT_DIR$/bar/subDir/bar.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="EMPTY_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -14,6 +14,7 @@ import com.intellij.testFramework.ApplicationRule
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.TemporaryDirectory
|
||||
import com.intellij.testFramework.loadProjectAndCheckResults
|
||||
import com.intellij.util.CommonProcessors
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Rule
|
||||
@@ -60,10 +61,24 @@ class ReloadProjectTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `add module from subdirectory`() {
|
||||
loadProjectAndCheckResults("addModuleFromSubDir/initial") { project ->
|
||||
val module = ModuleManager.getInstance(project).modules.single()
|
||||
assertThat(module.name).isEqualTo("foo")
|
||||
copyFilesAndReload(project, "addModuleFromSubDir/update")
|
||||
assertThat(ModuleManager.getInstance(project).modules).hasSize(2)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun copyFilesAndReload(project: Project, relativePath: String) {
|
||||
val base = Paths.get(project.basePath!!)
|
||||
val projectDir = VfsUtil.findFile(base, true)!!
|
||||
//process all files to ensure that they all are loaded in VFS and we'll get events when they are changed
|
||||
VfsUtil.processFilesRecursively(projectDir, CommonProcessors.alwaysTrue())
|
||||
|
||||
FileUtil.copyDir(testDataRoot.resolve(relativePath).toFile(), base.toFile())
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, VfsUtil.findFile(base, true))
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, projectDir)
|
||||
StoreReloadManager.getInstance().reloadChangedStorageFiles()
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,10 @@ class JpsProjectSerializersImpl(directorySerializersFactories: List<JpsDirectory
|
||||
fileSerializersByUrl.remove(obsoleteSerializer.fileUrl.url, obsoleteSerializer)
|
||||
}
|
||||
|
||||
val affectedFileLoaders = (change.changedFileUrls + addedFileUrls).toCollection(HashSet()).flatMap { fileSerializersByUrl.getValues(it) }
|
||||
val affectedFileLoaders = LinkedHashSet<JpsFileEntitiesSerializer<*>>(newFileSerializers)
|
||||
addedFileUrls.flatMapTo(affectedFileLoaders) { fileSerializersByUrl.getValues(it) }
|
||||
change.changedFileUrls.flatMapTo(affectedFileLoaders) { fileSerializersByUrl.getValues(it) }
|
||||
|
||||
val changedSources = affectedFileLoaders.mapTo(HashSet()) { it.internalEntitySource }
|
||||
for (fileUrl in change.removedFileUrls) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user