Add setting to enable JS IC for JPS

#KT-25565 fixed
This commit is contained in:
Alexey Tsvetkov
2018-07-18 14:06:55 +03:00
parent 0b18380770
commit eef40a5940
5 changed files with 54 additions and 35 deletions
@@ -21,11 +21,11 @@ import org.jetbrains.annotations.TestOnly;
import java.util.List; import java.util.List;
public class IncrementalCompilation { public class IncrementalCompilation {
private static final String INCREMENTAL_COMPILATION_PROPERTY = "kotlin.incremental.compilation"; public static final String INCREMENTAL_COMPILATION_JVM_PROPERTY = "kotlin.incremental.compilation";
private static final String INCREMENTAL_COMPILATION_JS_PROPERTY = "kotlin.incremental.compilation.js"; public static final String INCREMENTAL_COMPILATION_JS_PROPERTY = "kotlin.incremental.compilation.js";
public static boolean isEnabledForJvm() { public static boolean isEnabledForJvm() {
return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_PROPERTY)); return "true".equals(System.getProperty(INCREMENTAL_COMPILATION_JVM_PROPERTY));
} }
public static boolean isEnabledForJs() { public static boolean isEnabledForJs() {
@@ -34,7 +34,7 @@ public class IncrementalCompilation {
@TestOnly @TestOnly
public static void setIsEnabled(boolean value) { public static void setIsEnabled(boolean value) {
System.setProperty(INCREMENTAL_COMPILATION_PROPERTY, String.valueOf(value)); System.setProperty(INCREMENTAL_COMPILATION_JVM_PROPERTY, String.valueOf(value));
} }
@TestOnly @TestOnly
@@ -43,7 +43,7 @@ public class IncrementalCompilation {
} }
public static void toJvmArgs(List<String> jvmArgs) { public static void toJvmArgs(List<String> jvmArgs) {
if (isEnabledForJvm()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_PROPERTY); if (isEnabledForJvm()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JVM_PROPERTY);
if (isEnabledForJs()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JS_PROPERTY); if (isEnabledForJs()) addJvmSystemFlag(jvmArgs, INCREMENTAL_COMPILATION_JS_PROPERTY);
} }
@@ -23,12 +23,14 @@ import com.intellij.openapi.components.StoragePathMacros
import com.intellij.util.xmlb.XmlSerializerUtil import com.intellij.util.xmlb.XmlSerializerUtil
@State( @State(
name = "KotlinCompilerWorkspaceSettings", name = "KotlinCompilerWorkspaceSettings",
storages = arrayOf( storages = arrayOf(
Storage(file = StoragePathMacros.WORKSPACE_FILE) Storage(file = StoragePathMacros.WORKSPACE_FILE)
) )
) class KotlinCompilerWorkspaceSettings : PersistentStateComponent<KotlinCompilerWorkspaceSettings> { )
class KotlinCompilerWorkspaceSettings : PersistentStateComponent<KotlinCompilerWorkspaceSettings> {
var preciseIncrementalEnabled: Boolean = true var preciseIncrementalEnabled: Boolean = true
var incrementalCompilationForJsEnabled: Boolean = false
var enableDaemon: Boolean = true var enableDaemon: Boolean = true
override fun getState(): KotlinCompilerWorkspaceSettings { override fun getState(): KotlinCompilerWorkspaceSettings {
@@ -17,15 +17,20 @@
package org.jetbrains.kotlin.idea.compiler.configuration package org.jetbrains.kotlin.idea.compiler.configuration
import com.intellij.compiler.server.BuildProcessParametersProvider import com.intellij.compiler.server.BuildProcessParametersProvider
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.idea.PluginStartupComponent import org.jetbrains.kotlin.idea.PluginStartupComponent
class KotlinBuildProcessParametersProvider(private val compilerWorkspaceSettings: KotlinCompilerWorkspaceSettings, class KotlinBuildProcessParametersProvider(
private val kotlinPluginStartupComponent: PluginStartupComponent private val compilerWorkspaceSettings: KotlinCompilerWorkspaceSettings,
): BuildProcessParametersProvider() { private val kotlinPluginStartupComponent: PluginStartupComponent
) : BuildProcessParametersProvider() {
override fun getVMArguments(): MutableList<String> { override fun getVMArguments(): MutableList<String> {
val res = arrayListOf<String>() val res = arrayListOf<String>()
if (compilerWorkspaceSettings.preciseIncrementalEnabled) { if (compilerWorkspaceSettings.preciseIncrementalEnabled) {
res.add("-Dkotlin.incremental.compilation=true") res.add("-D" + IncrementalCompilation.INCREMENTAL_COMPILATION_JVM_PROPERTY + "=true")
}
if (compilerWorkspaceSettings.incrementalCompilationForJsEnabled) {
res.add("-D" + IncrementalCompilation.INCREMENTAL_COMPILATION_JS_PROPERTY + "=true")
} }
if (compilerWorkspaceSettings.enableDaemon) { if (compilerWorkspaceSettings.enableDaemon) {
res.add("-Dkotlin.daemon.enabled") res.add("-Dkotlin.daemon.enabled")
@@ -15,7 +15,7 @@
<grid row="11" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="11" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> </vspacer>
<grid id="98e8a" binding="k2jsPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="98e8a" binding="k2jsPanel" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="true"/> <grid row="8" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="true"/>
@@ -30,7 +30,7 @@
<children> <children>
<component id="3ac8f" class="javax.swing.JLabel" binding="labelForOutputPrefixFile"> <component id="3ac8f" class="javax.swing.JLabel" binding="labelForOutputPrefixFile">
<constraints> <constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.js.option.output.prefix"/> <text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.js.option.output.prefix"/>
@@ -38,13 +38,13 @@
</component> </component>
<component id="dd0c2" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputPrefixFile"> <component id="dd0c2" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputPrefixFile">
<constraints> <constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
<component id="70326" class="javax.swing.JLabel" binding="labelForOutputPostfixFile"> <component id="70326" class="javax.swing.JLabel" binding="labelForOutputPostfixFile">
<constraints> <constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.js.option.output.postfix"/> <text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.js.option.output.postfix"/>
@@ -52,13 +52,13 @@
</component> </component>
<component id="1bdb7" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputPostfixFile"> <component id="1bdb7" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputPostfixFile">
<constraints> <constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
<component id="b93a8" class="javax.swing.JLabel" binding="labelForOutputDirectory"> <component id="b93a8" class="javax.swing.JLabel" binding="labelForOutputDirectory">
<constraints> <constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/> <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="&amp;Destination directory"/> <text value="&amp;Destination directory"/>
@@ -66,7 +66,7 @@
</component> </component>
<component id="7c11a" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputDirectory"> <component id="7c11a" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputDirectory">
<constraints> <constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -76,7 +76,7 @@
</component> </component>
<component id="97317" class="com.intellij.util.ui.ThreeStateCheckBox" binding="copyRuntimeFilesCheckBox" custom-create="true"> <component id="97317" class="com.intellij.util.ui.ThreeStateCheckBox" binding="copyRuntimeFilesCheckBox" custom-create="true">
<constraints> <constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<state value="NOT_SELECTED"/> <state value="NOT_SELECTED"/>
@@ -85,7 +85,7 @@
</component> </component>
<component id="915d" class="javax.swing.JLabel"> <component id="915d" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<labelFor value="ca29c"/> <labelFor value="ca29c"/>
@@ -94,7 +94,7 @@
</component> </component>
<component id="ca29c" class="javax.swing.JComboBox" binding="moduleKindComboBox"> <component id="ca29c" class="javax.swing.JComboBox" binding="moduleKindComboBox">
<constraints> <constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> <grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<model/> <model/>
@@ -102,7 +102,7 @@
</component> </component>
<component id="e1cc8" class="com.intellij.util.ui.ThreeStateCheckBox" binding="generateSourceMapsCheckBox" default-binding="true"> <component id="e1cc8" class="com.intellij.util.ui.ThreeStateCheckBox" binding="generateSourceMapsCheckBox" default-binding="true">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<state value="NOT_SELECTED"/> <state value="NOT_SELECTED"/>
@@ -111,7 +111,7 @@
</component> </component>
<component id="6484c" class="javax.swing.JLabel" binding="labelForSourceMapPrefix"> <component id="6484c" class="javax.swing.JLabel" binding="labelForSourceMapPrefix">
<constraints> <constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<labelFor value="e65e6"/> <labelFor value="e65e6"/>
@@ -120,7 +120,7 @@
</component> </component>
<component id="e65e6" class="javax.swing.JTextField" binding="sourceMapPrefix"> <component id="e65e6" class="javax.swing.JTextField" binding="sourceMapPrefix">
<constraints> <constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -128,7 +128,7 @@
</component> </component>
<component id="e5314" class="javax.swing.JLabel"> <component id="e5314" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Embed source code into source map:"/> <text value="Embed source code into source map:"/>
@@ -136,10 +136,18 @@
</component> </component>
<component id="48310" class="javax.swing.JComboBox" binding="sourceMapEmbedSources"> <component id="48310" class="javax.swing.JComboBox" binding="sourceMapEmbedSources">
<constraints> <constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
<component id="6f3" class="javax.swing.JCheckBox" binding="enableIncrementalCompilationForJsCheckBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable incremental compilation (experimental)"/>
</properties>
</component>
</children> </children>
</grid> </grid>
<grid id="483d4" binding="scriptPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="483d4" binding="scriptPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -247,12 +255,12 @@
<text value="Target &amp;JVM version"/> <text value="Target &amp;JVM version"/>
</properties> </properties>
</component> </component>
<component id="d8f92" class="javax.swing.JCheckBox" binding="enablePreciseIncrementalCheckBox"> <component id="d8f92" class="javax.swing.JCheckBox" binding="enableIncrementalCompilationForJvmCheckBox">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Enable precise incremental compilation"/> <text value="Enable incremental compilation"/>
</properties> </properties>
</component> </component>
<component id="769be" class="javax.swing.JComboBox" binding="jvmVersionComboBox"> <component id="769be" class="javax.swing.JComboBox" binding="jvmVersionComboBox">
@@ -88,7 +88,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
private TextFieldWithBrowseButton outputDirectory; private TextFieldWithBrowseButton outputDirectory;
private ThreeStateCheckBox copyRuntimeFilesCheckBox; private ThreeStateCheckBox copyRuntimeFilesCheckBox;
private ThreeStateCheckBox keepAliveCheckBox; private ThreeStateCheckBox keepAliveCheckBox;
private JCheckBox enablePreciseIncrementalCheckBox; private JCheckBox enableIncrementalCompilationForJvmCheckBox;
private JCheckBox enableIncrementalCompilationForJsCheckBox;
private JComboBox moduleKindComboBox; private JComboBox moduleKindComboBox;
private JCheckBox scriptDependenciesAutoReload; private JCheckBox scriptDependenciesAutoReload;
private JTextField scriptTemplatesField; private JTextField scriptTemplatesField;
@@ -438,7 +439,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
isModified(outputDirectory, compilerSettings.getOutputDirectoryForJsLibraryFiles()) || isModified(outputDirectory, compilerSettings.getOutputDirectoryForJsLibraryFiles()) ||
(compilerWorkspaceSettings != null && (compilerWorkspaceSettings != null &&
(isModified(enablePreciseIncrementalCheckBox, compilerWorkspaceSettings.getPreciseIncrementalEnabled()) || (isModified(enableIncrementalCompilationForJvmCheckBox, compilerWorkspaceSettings.getPreciseIncrementalEnabled()) ||
isModified(enableIncrementalCompilationForJsCheckBox, compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()) ||
isModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) || isModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) ||
isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) || isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) ||
@@ -528,7 +530,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
getScriptingSettings().setAutoReloadEnabled(scriptDependenciesAutoReload.isSelected()); getScriptingSettings().setAutoReloadEnabled(scriptDependenciesAutoReload.isSelected());
if (compilerWorkspaceSettings != null) { if (compilerWorkspaceSettings != null) {
compilerWorkspaceSettings.setPreciseIncrementalEnabled(enablePreciseIncrementalCheckBox.isSelected()); compilerWorkspaceSettings.setPreciseIncrementalEnabled(enableIncrementalCompilationForJvmCheckBox.isSelected());
compilerWorkspaceSettings.setIncrementalCompilationForJsEnabled(enableIncrementalCompilationForJsCheckBox.isSelected());
boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon(); boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon();
compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected()); compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected());
@@ -579,7 +582,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles()); outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles());
if (compilerWorkspaceSettings != null) { if (compilerWorkspaceSettings != null) {
enablePreciseIncrementalCheckBox.setSelected(compilerWorkspaceSettings.getPreciseIncrementalEnabled()); enableIncrementalCompilationForJvmCheckBox.setSelected(compilerWorkspaceSettings.getPreciseIncrementalEnabled());
enableIncrementalCompilationForJsCheckBox.setSelected(compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled());
keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon()); keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon());
} }