Report warning for several modules with same name on module path
This commit is contained in:
@@ -154,8 +154,16 @@ internal class ClasspathRootsResolver(
|
||||
}
|
||||
|
||||
for (module in modules) {
|
||||
// TODO: report a diagnostic if a module with this name was already added
|
||||
javaModuleFinder.addUserModule(module)
|
||||
val existing = javaModuleFinder.findModule(module.name)
|
||||
if (existing == null) {
|
||||
javaModuleFinder.addUserModule(module)
|
||||
}
|
||||
else if (module.moduleRoot != existing.moduleRoot) {
|
||||
val jar = VfsUtilCore.getVirtualFileForJar(module.moduleRoot) ?: module.moduleRoot
|
||||
val existingPath = (VfsUtilCore.getVirtualFileForJar(existing.moduleRoot) ?: existing.moduleRoot).path
|
||||
report(STRONG_WARNING, "The root is ignored because a module with the same name '${module.name}' " +
|
||||
"has been found earlier on the module path at: $existingPath", jar)
|
||||
}
|
||||
}
|
||||
|
||||
if (javaModuleFinder.allObservableModules.none()) return
|
||||
|
||||
@@ -26,13 +26,8 @@ import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
|
||||
internal class CliJavaModuleFinder(private val jrtFileSystem: VirtualFileSystem?) : JavaModuleFinder {
|
||||
private val userModules = linkedMapOf<String, JavaModule>()
|
||||
|
||||
/**
|
||||
* @return true if the module was added successfully, false otherwise
|
||||
*/
|
||||
fun addUserModule(module: JavaModule): Boolean {
|
||||
if (module.name in userModules) return false
|
||||
userModules[module.name] = module
|
||||
return true
|
||||
fun addUserModule(module: JavaModule) {
|
||||
userModules.putIfAbsent(module.name, module)
|
||||
}
|
||||
|
||||
val allObservableModules: Sequence<JavaModule>
|
||||
|
||||
Reference in New Issue
Block a user