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">
|
<fileset dir="idea/src">
|
||||||
<include name="META-INF/extensions/common.xml"/>
|
<include name="META-INF/extensions/common.xml"/>
|
||||||
<include name="META-INF/extensions/kotlin2jvm.xml"/>
|
|
||||||
<include name="META-INF/extensions/kotlin2js.xml"/>
|
|
||||||
</fileset>
|
</fileset>
|
||||||
|
|
||||||
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
||||||
|
|||||||
@@ -77,9 +77,7 @@ val jar: Jar by tasks
|
|||||||
jar.apply {
|
jar.apply {
|
||||||
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||||
from("../idea/src").apply {
|
from("../idea/src").apply {
|
||||||
include("META-INF/extensions/common.xml",
|
include("META-INF/extensions/common.xml")
|
||||||
"META-INF/extensions/kotlin2jvm.xml",
|
|
||||||
"META-INF/extensions/kotlin2js.xml")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,23 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public enum EnvironmentConfigFiles {
|
public enum EnvironmentConfigFiles {
|
||||||
JVM_CONFIG_FILES("extensions/common.xml", "extensions/kotlin2jvm.xml"),
|
JVM_CONFIG_FILES,
|
||||||
JS_CONFIG_FILES("extensions/common.xml", "extensions/kotlin2js.xml"),
|
JS_CONFIG_FILES,
|
||||||
NATIVE_CONFIG_FILES("extensions/common.xml"),
|
NATIVE_CONFIG_FILES,
|
||||||
METADATA_CONFIG_FILES("extensions/common.xml"),
|
METADATA_CONFIG_FILES,
|
||||||
EMPTY();
|
|
||||||
|
|
||||||
private final List<String> files;
|
|
||||||
|
|
||||||
EnvironmentConfigFiles(String... fileArray) {
|
|
||||||
files = Arrays.asList(fileArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getFiles() {
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,8 +110,6 @@ import org.jetbrains.kotlin.script.StandardScriptDefinition
|
|||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
import kotlin.reflect.full.declaredMemberProperties
|
|
||||||
import kotlin.reflect.jvm.isAccessible
|
|
||||||
|
|
||||||
class KotlinCoreEnvironment private constructor(
|
class KotlinCoreEnvironment private constructor(
|
||||||
parentDisposable: Disposable,
|
parentDisposable: Disposable,
|
||||||
@@ -385,14 +383,15 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
private var ourApplicationEnvironment: JavaCoreApplicationEnvironment? = null
|
private var ourApplicationEnvironment: JavaCoreApplicationEnvironment? = null
|
||||||
private var ourProjectCount = 0
|
private var ourProjectCount = 0
|
||||||
|
|
||||||
@JvmStatic fun createForProduction(
|
@JvmStatic
|
||||||
|
fun createForProduction(
|
||||||
parentDisposable: Disposable, configuration: CompilerConfiguration, configFiles: EnvironmentConfigFiles
|
parentDisposable: Disposable, configuration: CompilerConfiguration, configFiles: EnvironmentConfigFiles
|
||||||
): KotlinCoreEnvironment {
|
): KotlinCoreEnvironment {
|
||||||
setCompatibleBuild()
|
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
|
// 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
|
// 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)
|
// 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
|
// All projects share the same ApplicationEnvironment, and when the last project is disposed, the ApplicationEnvironment is disposed as well
|
||||||
Disposer.register(parentDisposable, Disposable {
|
Disposer.register(parentDisposable, Disposable {
|
||||||
@@ -418,33 +417,33 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
@JvmStatic fun createForTests(
|
@JvmStatic
|
||||||
parentDisposable: Disposable, configuration: CompilerConfiguration, extensionConfigs: EnvironmentConfigFiles
|
fun createForTests(
|
||||||
|
parentDisposable: Disposable, initialConfiguration: CompilerConfiguration, extensionConfigs: EnvironmentConfigFiles
|
||||||
): KotlinCoreEnvironment {
|
): KotlinCoreEnvironment {
|
||||||
val config = configuration.copy()
|
val configuration = initialConfiguration.copy()
|
||||||
if (config.getList(JVMConfigurationKeys.SCRIPT_DEFINITIONS).isEmpty()) {
|
if (configuration.getList(JVMConfigurationKeys.SCRIPT_DEFINITIONS).isEmpty()) {
|
||||||
config.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition)
|
configuration.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition)
|
||||||
}
|
}
|
||||||
// Tests are supposed to create a single project and dispose it right after use
|
// Tests are supposed to create a single project and dispose it right after use
|
||||||
return KotlinCoreEnvironment(parentDisposable,
|
return KotlinCoreEnvironment(
|
||||||
createApplicationEnvironment(parentDisposable, config, extensionConfigs.files,
|
parentDisposable,
|
||||||
unitTestMode = true),
|
createApplicationEnvironment(parentDisposable, configuration, unitTestMode = true),
|
||||||
config,
|
configuration,
|
||||||
extensionConfigs)
|
extensionConfigs
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// used in the daemon for jar cache cleanup
|
// used in the daemon for jar cache cleanup
|
||||||
val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment
|
val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment
|
||||||
|
|
||||||
private fun getOrCreateApplicationEnvironmentForProduction(
|
private fun getOrCreateApplicationEnvironmentForProduction(configuration: CompilerConfiguration): JavaCoreApplicationEnvironment {
|
||||||
configuration: CompilerConfiguration, configFilePaths: List<String>
|
|
||||||
): JavaCoreApplicationEnvironment {
|
|
||||||
synchronized (APPLICATION_LOCK) {
|
synchronized (APPLICATION_LOCK) {
|
||||||
if (ourApplicationEnvironment != null)
|
if (ourApplicationEnvironment != null)
|
||||||
return ourApplicationEnvironment!!
|
return ourApplicationEnvironment!!
|
||||||
|
|
||||||
val parentDisposable = Disposer.newDisposable()
|
val parentDisposable = Disposer.newDisposable()
|
||||||
ourApplicationEnvironment = createApplicationEnvironment(parentDisposable, configuration, configFilePaths, unitTestMode = false)
|
ourApplicationEnvironment = createApplicationEnvironment(parentDisposable, configuration, unitTestMode = false)
|
||||||
ourProjectCount = 0
|
ourProjectCount = 0
|
||||||
Disposer.register(parentDisposable, Disposable {
|
Disposer.register(parentDisposable, Disposable {
|
||||||
synchronized (APPLICATION_LOCK) {
|
synchronized (APPLICATION_LOCK) {
|
||||||
@@ -467,7 +466,6 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
private fun createApplicationEnvironment(
|
private fun createApplicationEnvironment(
|
||||||
parentDisposable: Disposable,
|
parentDisposable: Disposable,
|
||||||
configuration: CompilerConfiguration,
|
configuration: CompilerConfiguration,
|
||||||
configFilePaths: List<String>,
|
|
||||||
unitTestMode: Boolean
|
unitTestMode: Boolean
|
||||||
): JavaCoreApplicationEnvironment {
|
): JavaCoreApplicationEnvironment {
|
||||||
Extensions.cleanRootArea(parentDisposable)
|
Extensions.cleanRootArea(parentDisposable)
|
||||||
@@ -476,9 +474,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
override fun createJrtFileSystem(): VirtualFileSystem? = CoreJrtFileSystem()
|
override fun createJrtFileSystem(): VirtualFileSystem? = CoreJrtFileSystem()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (configPath in configFilePaths) {
|
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/common.xml")
|
||||||
registerApplicationExtensionPointsAndExtensionsFrom(configuration, configPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
registerApplicationServicesForCLI(applicationEnvironment)
|
registerApplicationServicesForCLI(applicationEnvironment)
|
||||||
registerApplicationServices(applicationEnvironment)
|
registerApplicationServices(applicationEnvironment)
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ class Preprocessor(val logger: Logger = SystemOutLogger) {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val configuration = CompilerConfiguration()
|
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
|
val project = environment.project
|
||||||
jetPsiFactory = KtPsiFactory(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>
|
</extensionPoints>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
<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"/>
|
<quickFixContributor implementation="org.jetbrains.kotlin.idea.quickfix.QuickFixRegistrar"/>
|
||||||
|
|
||||||
<declarationAttributeAltererExtension implementation="org.jetbrains.kotlin.allopen.ide.IdeAllOpenDeclarationAttributeAltererExtension"/>
|
<declarationAttributeAltererExtension implementation="org.jetbrains.kotlin.allopen.ide.IdeAllOpenDeclarationAttributeAltererExtension"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user