Minor, invert JavaModule.isBinary -> isSourceModule
This commit is contained in:
@@ -161,7 +161,9 @@ class ClasspathRootsResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addModularRoots(modules: List<JavaModule>, result: MutableList<JavaRoot>) {
|
private fun addModularRoots(modules: List<JavaModule>, result: MutableList<JavaRoot>) {
|
||||||
val sourceModules = modules.filterIsInstance<JavaModule.Explicit>().filterNot(JavaModule::isBinary)
|
// In current implementation, at most one source module is supported. This can be relaxed in the future if we support another
|
||||||
|
// compilation mode, similar to java's --module-source-path
|
||||||
|
val sourceModules = modules.filterIsInstance<JavaModule.Explicit>().filter(JavaModule::isSourceModule)
|
||||||
if (sourceModules.size > 1) {
|
if (sourceModules.size > 1) {
|
||||||
for (module in sourceModules) {
|
for (module in sourceModules) {
|
||||||
report(ERROR, "Too many source module declarations found", module.moduleInfoFile)
|
report(ERROR, "Too many source module declarations found", module.moduleInfoFile)
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ class CliJavaModuleResolver(
|
|||||||
private val systemModules: List<JavaModule.Explicit>
|
private val systemModules: List<JavaModule.Explicit>
|
||||||
) : JavaModuleResolver {
|
) : JavaModuleResolver {
|
||||||
init {
|
init {
|
||||||
assert(userModules.count { !it.isBinary } <= 1) {
|
assert(userModules.count(JavaModule::isSourceModule) <= 1) {
|
||||||
"Modules computed by ClasspathRootsResolver cannot have more than one source module: $userModules"
|
"Modules computed by ClasspathRootsResolver cannot have more than one source module: $userModules"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val sourceModule: JavaModule? = userModules.firstOrNull { !it.isBinary }
|
private val sourceModule: JavaModule? = userModules.firstOrNull(JavaModule::isSourceModule)
|
||||||
|
|
||||||
private fun findJavaModule(file: VirtualFile): JavaModule? {
|
private fun findJavaModule(file: VirtualFile): JavaModule? {
|
||||||
if (file.fileSystem.protocol == StandardFileSystems.JRT_PROTOCOL) {
|
if (file.fileSystem.protocol == StandardFileSystems.JRT_PROTOCOL) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.jvm.modules
|
package org.jetbrains.kotlin.resolve.jvm.modules
|
||||||
|
|
||||||
import com.intellij.ide.highlighter.JavaClassFileType
|
import com.intellij.ide.highlighter.JavaFileType
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
@@ -41,10 +41,11 @@ interface JavaModule {
|
|||||||
val moduleInfoFile: VirtualFile?
|
val moduleInfoFile: VirtualFile?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `true` if this module is either an automatic module on the module path, or an explicit module loaded from module-info.class.
|
* `true` if this module is an explicit module loaded from module-info.java, `false` otherwise. This usually corresponds to the module
|
||||||
* `false` if this module is an explicit module loaded from module-info.java.
|
* currently being compiled.
|
||||||
|
* Note that in case of partial/incremental compilation, the source module may contain both binary roots and non-binary roots.
|
||||||
*/
|
*/
|
||||||
val isBinary: Boolean
|
val isSourceModule: Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `true` if this module exports the package with the given FQ name to all dependent modules.
|
* `true` if this module exports the package with the given FQ name to all dependent modules.
|
||||||
@@ -70,7 +71,7 @@ interface JavaModule {
|
|||||||
class Automatic(override val name: String, override val moduleRoots: List<Root>) : JavaModule {
|
class Automatic(override val name: String, override val moduleRoots: List<Root>) : JavaModule {
|
||||||
override val moduleInfoFile: VirtualFile? get() = null
|
override val moduleInfoFile: VirtualFile? get() = null
|
||||||
|
|
||||||
override val isBinary: Boolean get() = true
|
override val isSourceModule: Boolean get() = false
|
||||||
|
|
||||||
override fun exports(packageFqName: FqName): Boolean = true
|
override fun exports(packageFqName: FqName): Boolean = true
|
||||||
|
|
||||||
@@ -87,8 +88,8 @@ interface JavaModule {
|
|||||||
override val name: String
|
override val name: String
|
||||||
get() = moduleInfo.moduleName
|
get() = moduleInfo.moduleName
|
||||||
|
|
||||||
override val isBinary: Boolean
|
override val isSourceModule: Boolean
|
||||||
get() = moduleInfoFile.fileType == JavaClassFileType.INSTANCE
|
get() = moduleInfoFile.fileType == JavaFileType.INSTANCE
|
||||||
|
|
||||||
override fun exports(packageFqName: FqName): Boolean {
|
override fun exports(packageFqName: FqName): Boolean {
|
||||||
return moduleInfo.exports.any { (fqName, toModules) ->
|
return moduleInfo.exports.any { (fqName, toModules) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user