JS: disable JVM specific part of internal visibility resolution
This commit is contained in:
@@ -42,6 +42,8 @@ class ModuleVisibilityHelperImpl : ModuleVisibilityHelper {
|
||||
}
|
||||
|
||||
val moduleVisibilityManager = ModuleVisibilityManager.SERVICE.getInstance(project)
|
||||
if (!moduleVisibilityManager.enabled) return true
|
||||
|
||||
moduleVisibilityManager.friendPaths.forEach {
|
||||
if (isContainedByCompiledPartOfOurModule(what, File(it))) return true
|
||||
}
|
||||
@@ -82,7 +84,7 @@ class ModuleVisibilityHelperImpl : ModuleVisibilityHelper {
|
||||
At the moment, there is no proper support for module infrastructure in the compiler.
|
||||
So we add try to remember given list of interdependent modules and use it for checking visibility.
|
||||
*/
|
||||
class CliModuleVisibilityManagerImpl() : ModuleVisibilityManager, Disposable {
|
||||
class CliModuleVisibilityManagerImpl(override val enabled: Boolean) : ModuleVisibilityManager, Disposable {
|
||||
override val chunk: MutableList<Module> = arrayListOf()
|
||||
override val friendPaths: MutableList <String> = arrayListOf()
|
||||
|
||||
|
||||
@@ -19,16 +19,18 @@ package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class EnvironmentConfigFiles {
|
||||
public enum EnvironmentConfigFiles {
|
||||
JVM_CONFIG_FILES("extensions/common.xml", "extensions/kotlin2jvm.xml"),
|
||||
JS_CONFIG_FILES("extensions/common.xml", "extensions/kotlin2js.xml"),
|
||||
EMPTY();
|
||||
|
||||
private static final String EXTENSIONS_DIR = "extensions/";
|
||||
private final List<String> files;
|
||||
|
||||
private static final String COMMON_CONFIG_FILE = EXTENSIONS_DIR + "common.xml";
|
||||
private static final String JVM_CONFIG_FILE = EXTENSIONS_DIR + "kotlin2jvm.xml";
|
||||
private static final String JS_CONFIG_FILE = EXTENSIONS_DIR + "kotlin2js.xml";
|
||||
EnvironmentConfigFiles(String... fileArray) {
|
||||
files = Arrays.asList(fileArray);
|
||||
}
|
||||
|
||||
public static final List<String> JVM_CONFIG_FILES = Arrays.asList(COMMON_CONFIG_FILE, JVM_CONFIG_FILE);
|
||||
public static final List<String> JS_CONFIG_FILES = Arrays.asList(COMMON_CONFIG_FILE, JS_CONFIG_FILE);
|
||||
|
||||
private EnvironmentConfigFiles() {}
|
||||
public List<String> getFiles() {
|
||||
return files;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,8 @@ import java.io.File
|
||||
class KotlinCoreEnvironment private constructor(
|
||||
parentDisposable: Disposable,
|
||||
applicationEnvironment: JavaCoreApplicationEnvironment,
|
||||
configuration: CompilerConfiguration
|
||||
configuration: CompilerConfiguration,
|
||||
configFiles: EnvironmentConfigFiles
|
||||
) {
|
||||
|
||||
private val projectEnvironment: JavaCoreProjectEnvironment = object : KotlinCoreProjectEnvironment(parentDisposable, applicationEnvironment) {
|
||||
@@ -167,7 +168,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
}
|
||||
|
||||
project.registerService(DeclarationProviderFactoryService::class.java, CliDeclarationProviderFactoryService(sourceFiles))
|
||||
project.registerService(ModuleVisibilityManager::class.java, CliModuleVisibilityManagerImpl())
|
||||
project.registerService(ModuleVisibilityManager::class.java, CliModuleVisibilityManagerImpl(configFiles == EnvironmentConfigFiles.JVM_CONFIG_FILES))
|
||||
|
||||
registerProjectServicesForCLI(projectEnvironment)
|
||||
registerProjectServices(projectEnvironment)
|
||||
@@ -337,10 +338,10 @@ class KotlinCoreEnvironment private constructor(
|
||||
private var ourProjectCount = 0
|
||||
|
||||
@JvmStatic fun createForProduction(
|
||||
parentDisposable: Disposable, configuration: CompilerConfiguration, configFilePaths: List<String>
|
||||
parentDisposable: Disposable, configuration: CompilerConfiguration, configFiles: EnvironmentConfigFiles
|
||||
): KotlinCoreEnvironment {
|
||||
setCompatibleBuild()
|
||||
val appEnv = getOrCreateApplicationEnvironmentForProduction(configuration, configFilePaths)
|
||||
val appEnv = getOrCreateApplicationEnvironmentForProduction(configuration, configFiles.files)
|
||||
// Disposing of the environment is unsafe in production then parallel builds are enabled, but turning it off universally
|
||||
// breaks a lot of tests, therefore it is disabled for production and enabled for tests
|
||||
if (!(System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY).toBooleanLenient() ?: false)) {
|
||||
@@ -354,7 +355,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
}
|
||||
})
|
||||
}
|
||||
val environment = KotlinCoreEnvironment(parentDisposable, appEnv, configuration)
|
||||
val environment = KotlinCoreEnvironment(parentDisposable, appEnv, configuration, configFiles)
|
||||
|
||||
synchronized (APPLICATION_LOCK) {
|
||||
ourProjectCount++
|
||||
@@ -369,10 +370,13 @@ class KotlinCoreEnvironment private constructor(
|
||||
|
||||
@TestOnly
|
||||
@JvmStatic fun createForTests(
|
||||
parentDisposable: Disposable, configuration: CompilerConfiguration, extensionConfigs: List<String>
|
||||
parentDisposable: Disposable, configuration: CompilerConfiguration, extensionConfigs: EnvironmentConfigFiles
|
||||
): KotlinCoreEnvironment {
|
||||
// Tests are supposed to create a single project and dispose it right after use
|
||||
return KotlinCoreEnvironment(parentDisposable, createApplicationEnvironment(parentDisposable, configuration, extensionConfigs), configuration)
|
||||
return KotlinCoreEnvironment(parentDisposable,
|
||||
createApplicationEnvironment(parentDisposable, configuration, extensionConfigs.files),
|
||||
configuration,
|
||||
extensionConfigs)
|
||||
}
|
||||
|
||||
// used in the daemon for jar cache cleanup
|
||||
|
||||
Reference in New Issue
Block a user