UI to enable/disable compiler daemon

This commit is contained in:
Dmitry Jemerov
2015-09-11 15:00:18 +02:00
parent d5f2bf5666
commit 9f1bd123f9
5 changed files with 32 additions and 5 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.idea;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.components.ApplicationComponent;
import org.jetbrains.annotations.NotNull;
@@ -31,6 +32,10 @@ import java.io.IOException;
public class PluginStartupComponent implements ApplicationComponent {
private static final String KOTLIN_BUNDLED = "KOTLIN_BUNDLED";
public static PluginStartupComponent getInstance() {
return ApplicationManager.getApplication().getComponent(PluginStartupComponent.class);
}
@Override
@NotNull
public String getComponentName() {
@@ -27,6 +27,9 @@ public class KotlinBuildProcessParametersProvider(private val compilerWorkspaceS
if (!compilerWorkspaceSettings.incrementalCompilationEnabled) {
res.add("-Dkotlin.incremental.compilation=false")
}
if (compilerWorkspaceSettings.enableDaemon) {
res.add("-Dkotlin.daemon.enabled")
}
kotlinPluginStartupComponent.aliveFlagPath.let {
if (!it.isBlank()) {
// TODO: consider taking the property name from compiler/rmi-interface (check whether dependency will be not too heavy)
@@ -3,7 +3,7 @@
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="467" height="357"/>
<xy x="20" y="20" width="594" height="357"/>
</constraints>
<properties/>
<border type="none"/>
@@ -13,7 +13,7 @@
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="27e96" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27e96" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
@@ -48,6 +48,14 @@
<dialogCaption resource-bundle="org/jetbrains/kotlin/idea/JetBundle" key="kotlin.compiler.option.additional.command.line.parameters.dialog.title"/>
</properties>
</component>
<component id="c45a6" class="javax.swing.JCheckBox" binding="keepAliveCheckBox">
<constraints>
<grid row="2" 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>
<properties>
<text value="Keep compiler process alive between invocations (experimental)"/>
</properties>
</component>
</children>
</grid>
<grid id="2f977" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
import org.jetbrains.kotlin.config.CompilerSettings;
import org.jetbrains.kotlin.idea.JetBundle;
import org.jetbrains.kotlin.idea.PluginStartupComponent;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@@ -58,6 +59,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
private JLabel labelForOutputDirectory;
private JTextField outputDirectory;
private JCheckBox copyRuntimeFilesCheckBox;
private JCheckBox keepAliveCheckBox;
public KotlinCompilerConfigurableTab(ConfigurableEP ep) {
this.extPoint = ep;
@@ -109,6 +111,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
ComparingUtils.isModified(outputDirectory, compilerSettings.getOutputDirectoryForJsLibraryFiles()) ||
ComparingUtils.isModified(incrementalCompilationCheckBox, compilerWorkspaceSettings.getIncrementalCompilationEnabled()) ||
ComparingUtils.isModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()) ||
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
@@ -124,6 +127,12 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
compilerWorkspaceSettings.setIncrementalCompilationEnabled(incrementalCompilationCheckBox.isSelected());
boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon();
compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected());
if (keepAliveCheckBox.isSelected() != oldEnableDaemon) {
PluginStartupComponent.getInstance().resetAliveFlag();
}
k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected();
k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true);
k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
@@ -137,6 +146,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles());
incrementalCompilationCheckBox.setSelected(compilerWorkspaceSettings.getIncrementalCompilationEnabled());
keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon());
generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap);
outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix);
@@ -17,12 +17,12 @@
package org.jetbrains.kotlin.idea.compiler.configuration
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.util.xmlb.XmlSerializerUtil
import com.intellij.openapi.components.StoragePathMacros
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.StoragePathMacros
import com.intellij.util.xmlb.XmlSerializerUtil
State(
@State(
name = "KotlinCompilerWorkspaceSettings",
storages = arrayOf(
Storage(file = StoragePathMacros.WORKSPACE_FILE)
@@ -30,6 +30,7 @@ State(
)
public class KotlinCompilerWorkspaceSettings() : PersistentStateComponent<KotlinCompilerWorkspaceSettings> {
public var incrementalCompilationEnabled: Boolean = true
public var enableDaemon: Boolean = false
override fun getState(): KotlinCompilerWorkspaceSettings {
return this