Remove idea/src/META-INF/extensions/{kotlin2jvm.xml,kotlin2js.xml}
Keep the EnvironmentConfigFiles enum because its values are used in determining whether the environment is going to be used for JVM or non-JVM project analysis, but remove the actual files. Drop EnvironmentConfigFiles.EMPTY and replace its only usage in preprocessor with JVM_CONFIG_FILES: it's easier and won't affect anything
This commit is contained in:
@@ -380,8 +380,6 @@
|
||||
|
||||
<fileset dir="idea/src">
|
||||
<include name="META-INF/extensions/common.xml"/>
|
||||
<include name="META-INF/extensions/kotlin2jvm.xml"/>
|
||||
<include name="META-INF/extensions/kotlin2js.xml"/>
|
||||
</fileset>
|
||||
|
||||
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
||||
|
||||
@@ -77,9 +77,7 @@ val jar: Jar by tasks
|
||||
jar.apply {
|
||||
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||
from("../idea/src").apply {
|
||||
include("META-INF/extensions/common.xml",
|
||||
"META-INF/extensions/kotlin2jvm.xml",
|
||||
"META-INF/extensions/kotlin2js.xml")
|
||||
include("META-INF/extensions/common.xml")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,23 +16,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum EnvironmentConfigFiles {
|
||||
JVM_CONFIG_FILES("extensions/common.xml", "extensions/kotlin2jvm.xml"),
|
||||
JS_CONFIG_FILES("extensions/common.xml", "extensions/kotlin2js.xml"),
|
||||
NATIVE_CONFIG_FILES("extensions/common.xml"),
|
||||
METADATA_CONFIG_FILES("extensions/common.xml"),
|
||||
EMPTY();
|
||||
|
||||
private final List<String> files;
|
||||
|
||||
EnvironmentConfigFiles(String... fileArray) {
|
||||
files = Arrays.asList(fileArray);
|
||||
}
|
||||
|
||||
public List<String> getFiles() {
|
||||
return files;
|
||||
}
|
||||
JVM_CONFIG_FILES,
|
||||
JS_CONFIG_FILES,
|
||||
NATIVE_CONFIG_FILES,
|
||||
METADATA_CONFIG_FILES,
|
||||
}
|
||||
|
||||
@@ -110,8 +110,6 @@ import org.jetbrains.kotlin.script.StandardScriptDefinition
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import java.util.zip.ZipFile
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
|
||||
class KotlinCoreEnvironment private constructor(
|
||||
parentDisposable: Disposable,
|
||||
@@ -385,14 +383,15 @@ class KotlinCoreEnvironment private constructor(
|
||||
private var ourApplicationEnvironment: JavaCoreApplicationEnvironment? = null
|
||||
private var ourProjectCount = 0
|
||||
|
||||
@JvmStatic fun createForProduction(
|
||||
@JvmStatic
|
||||
fun createForProduction(
|
||||
parentDisposable: Disposable, configuration: CompilerConfiguration, configFiles: EnvironmentConfigFiles
|
||||
): KotlinCoreEnvironment {
|
||||
setCompatibleBuild()
|
||||
val appEnv = getOrCreateApplicationEnvironmentForProduction(configuration, configFiles.files)
|
||||
val appEnv = getOrCreateApplicationEnvironmentForProduction(configuration)
|
||||
// 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)) {
|
||||
if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY).toBooleanLenient() != true) {
|
||||
// JPS may run many instances of the compiler in parallel (there's an option for compiling independent modules in parallel in IntelliJ)
|
||||
// All projects share the same ApplicationEnvironment, and when the last project is disposed, the ApplicationEnvironment is disposed as well
|
||||
Disposer.register(parentDisposable, Disposable {
|
||||
@@ -418,33 +417,33 @@ class KotlinCoreEnvironment private constructor(
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@JvmStatic fun createForTests(
|
||||
parentDisposable: Disposable, configuration: CompilerConfiguration, extensionConfigs: EnvironmentConfigFiles
|
||||
@JvmStatic
|
||||
fun createForTests(
|
||||
parentDisposable: Disposable, initialConfiguration: CompilerConfiguration, extensionConfigs: EnvironmentConfigFiles
|
||||
): KotlinCoreEnvironment {
|
||||
val config = configuration.copy()
|
||||
if (config.getList(JVMConfigurationKeys.SCRIPT_DEFINITIONS).isEmpty()) {
|
||||
config.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition)
|
||||
val configuration = initialConfiguration.copy()
|
||||
if (configuration.getList(JVMConfigurationKeys.SCRIPT_DEFINITIONS).isEmpty()) {
|
||||
configuration.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition)
|
||||
}
|
||||
// Tests are supposed to create a single project and dispose it right after use
|
||||
return KotlinCoreEnvironment(parentDisposable,
|
||||
createApplicationEnvironment(parentDisposable, config, extensionConfigs.files,
|
||||
unitTestMode = true),
|
||||
config,
|
||||
extensionConfigs)
|
||||
return KotlinCoreEnvironment(
|
||||
parentDisposable,
|
||||
createApplicationEnvironment(parentDisposable, configuration, unitTestMode = true),
|
||||
configuration,
|
||||
extensionConfigs
|
||||
)
|
||||
}
|
||||
|
||||
// used in the daemon for jar cache cleanup
|
||||
val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment
|
||||
|
||||
private fun getOrCreateApplicationEnvironmentForProduction(
|
||||
configuration: CompilerConfiguration, configFilePaths: List<String>
|
||||
): JavaCoreApplicationEnvironment {
|
||||
private fun getOrCreateApplicationEnvironmentForProduction(configuration: CompilerConfiguration): JavaCoreApplicationEnvironment {
|
||||
synchronized (APPLICATION_LOCK) {
|
||||
if (ourApplicationEnvironment != null)
|
||||
return ourApplicationEnvironment!!
|
||||
|
||||
val parentDisposable = Disposer.newDisposable()
|
||||
ourApplicationEnvironment = createApplicationEnvironment(parentDisposable, configuration, configFilePaths, unitTestMode = false)
|
||||
ourApplicationEnvironment = createApplicationEnvironment(parentDisposable, configuration, unitTestMode = false)
|
||||
ourProjectCount = 0
|
||||
Disposer.register(parentDisposable, Disposable {
|
||||
synchronized (APPLICATION_LOCK) {
|
||||
@@ -467,7 +466,6 @@ class KotlinCoreEnvironment private constructor(
|
||||
private fun createApplicationEnvironment(
|
||||
parentDisposable: Disposable,
|
||||
configuration: CompilerConfiguration,
|
||||
configFilePaths: List<String>,
|
||||
unitTestMode: Boolean
|
||||
): JavaCoreApplicationEnvironment {
|
||||
Extensions.cleanRootArea(parentDisposable)
|
||||
@@ -476,9 +474,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
override fun createJrtFileSystem(): VirtualFileSystem? = CoreJrtFileSystem()
|
||||
}
|
||||
|
||||
for (configPath in configFilePaths) {
|
||||
registerApplicationExtensionPointsAndExtensionsFrom(configuration, configPath)
|
||||
}
|
||||
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/common.xml")
|
||||
|
||||
registerApplicationServicesForCLI(applicationEnvironment)
|
||||
registerApplicationServices(applicationEnvironment)
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ class Preprocessor(val logger: Logger = SystemOutLogger) {
|
||||
|
||||
init {
|
||||
val configuration = CompilerConfiguration()
|
||||
val environment = KotlinCoreEnvironment.createForProduction(Disposable { }, configuration, EnvironmentConfigFiles.EMPTY)
|
||||
val environment = KotlinCoreEnvironment.createForProduction(Disposable { }, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
|
||||
val project = environment.project
|
||||
jetPsiFactory = KtPsiFactory(project)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<idea-plugin>
|
||||
<id>org.jetbrains.kotlin</id>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -1,6 +0,0 @@
|
||||
<idea-plugin>
|
||||
<id>org.jetbrains.kotlin</id>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -2725,8 +2725,6 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||
<xi:include href="extensions/kotlin2jvm.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
|
||||
<xi:include href="extensions/kotlin2js.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
|
||||
<quickFixContributor implementation="org.jetbrains.kotlin.idea.quickfix.QuickFixRegistrar"/>
|
||||
|
||||
<declarationAttributeAltererExtension implementation="org.jetbrains.kotlin.allopen.ide.IdeAllOpenDeclarationAttributeAltererExtension"/>
|
||||
|
||||
Reference in New Issue
Block a user