Incremental compilation checkbox in settings.

Old setting via VM option is automatically migrated to "new style".
This commit is contained in:
Evgeny Gerashchenko
2014-10-08 19:48:49 +04:00
parent 514a41ac77
commit 181b10103f
6 changed files with 117 additions and 3 deletions
+3
View File
@@ -159,6 +159,8 @@
<projectService serviceInterface="org.jetbrains.jet.plugin.compiler.configuration.KotlinCompilerSettings"
serviceImplementation="org.jetbrains.jet.plugin.compiler.configuration.KotlinCompilerSettings"/>
<projectService serviceImplementation="org.jetbrains.jet.plugin.compiler.configuration.KotlinCompilerWorkspaceSettings"/>
<projectService serviceInterface="org.jetbrains.jet.asJava.KotlinLightClassForPackage$FileStubCache"
serviceImplementation="org.jetbrains.jet.asJava.KotlinLightClassForPackage$FileStubCache"/>
@@ -189,6 +191,7 @@
<compileServer.plugin classpath="jps/kotlin-jps-plugin.jar;kotlin-runtime.jar;kotlin-plugin.jar"/>
<compiler.task execute="BEFORE" implementation="org.jetbrains.jet.plugin.internal.makeBackup.MakeBackupCompileTask"/>
<buildProcess.parametersProvider implementation="org.jetbrains.jet.plugin.compiler.configuration.KotlinBuildProcessParametersProvider"/>
<lang.syntaxHighlighterFactory key="jet" implementationClass="org.jetbrains.jet.plugin.highlighter.JetSyntaxHighlighterFactory"/>
<lang.braceMatcher language="jet" implementationClass="org.jetbrains.jet.plugin.JetPairMatcher"/>
@@ -16,11 +16,13 @@
package org.jetbrains.jet.plugin.compiler;
import com.intellij.compiler.CompilerWorkspaceConfiguration;
import com.intellij.diagnostic.PluginException;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.compiler.*;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtilRt;
@@ -29,6 +31,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.plugin.JetFileType;
import org.jetbrains.jet.plugin.compiler.configuration.KotlinCompilerWorkspaceSettings;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -44,7 +47,10 @@ public class JetCompilerManager implements ProjectComponent {
private static final String PREFIX_WITH_COMPILER_NAME = KOTLIN_COMPILER_NAME + ": " + INTERNAL_ERROR_PREFIX;
private static final Set<String> FILE_EXTS_WHICH_NEEDS_REFRESH = ContainerUtil.immutableSet(".js", ".map");
private final Project project;
public JetCompilerManager(Project project, CompilerManager manager) {
this.project = project;
manager.addCompilableFileType(JetFileType.INSTANCE);
manager.addCompilationStatusListener(new CompilationStatusListener() {
@Override
@@ -83,6 +89,18 @@ public class JetCompilerManager implements ProjectComponent {
@Override
public void initComponent() {
// TODO remove it after Kotlin M9
// Migrate incremental compilation option for early adopters only
String INCREMENTAL_VM_OPTION = "-Dkotlin.incremental.compilation=true";
CompilerWorkspaceConfiguration commonCompilerConfig = ServiceManager.getService(project, CompilerWorkspaceConfiguration.class);
String additionalVmOptions = commonCompilerConfig.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
if (additionalVmOptions.contains(INCREMENTAL_VM_OPTION)) {
String updatedVmOptions = additionalVmOptions.replace(INCREMENTAL_VM_OPTION, " ").trim();
commonCompilerConfig.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS = updatedVmOptions;
ServiceManager.getService(project, KotlinCompilerWorkspaceSettings.class).setIncrementalCompilationEnabled(true);
}
}
@Override
@@ -0,0 +1,29 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.plugin.compiler.configuration
import com.intellij.compiler.server.BuildProcessParametersProvider
import com.intellij.openapi.components.ServiceManager
public class KotlinBuildProcessParametersProvider(private val compilerWorkspaceSettings: KotlinCompilerWorkspaceSettings): BuildProcessParametersProvider() {
override fun getVMArguments(): MutableList<String> {
return if (compilerWorkspaceSettings.incrementalCompilationEnabled)
arrayListOf("-Dkotlin.incremental.compilation=true")
else
arrayListOf()
}
}
@@ -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="285"/>
<xy x="20" y="20" width="467" height="357"/>
</constraints>
<properties/>
<border type="none"/>
@@ -56,13 +56,22 @@
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<visible value="false"/>
<visible value="true"/>
</properties>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="etched" title-resource-bundle="org/jetbrains/jet/plugin/JetBundle" title-key="kotlin.compiler.jvm.option.panel.title"/>
<children/>
<children>
<component id="c6928" class="javax.swing.JCheckBox" binding="incrementalCompilationCheckBox">
<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>
</grid>
<grid id="98e8a" 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"/>
@@ -17,6 +17,7 @@
package org.jetbrains.jet.plugin.compiler.configuration;
import com.intellij.compiler.options.ComparingUtils;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableEP;
@@ -40,6 +41,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
private final CommonCompilerArguments commonCompilerArguments;
private final K2JSCompilerArguments k2jsCompilerArguments;
private final CompilerSettings compilerSettings;
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
private final ConfigurableEP extPoint;
private JPanel contentPane;
private JCheckBox generateNoWarningsCheckBox;
@@ -50,12 +52,14 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
private TextFieldWithBrowseButton outputPostfixFile;
private JLabel labelForOutputPrefixFile;
private JLabel labelForOutputPostfixFile;
private JCheckBox incrementalCompilationCheckBox;
public KotlinCompilerConfigurableTab(ConfigurableEP ep) {
this.extPoint = ep;
this.commonCompilerArguments = KotlinCommonCompilerArgumentsHolder.getInstance(ep.getProject()).getSettings();
this.k2jsCompilerArguments = Kotlin2JsCompilerArgumentsHolder.getInstance(ep.getProject()).getSettings();
this.compilerSettings = KotlinCompilerSettings.getInstance(ep.getProject()).getSettings();
this.compilerWorkspaceSettings = ServiceManager.getService(ep.getProject(), KotlinCompilerWorkspaceSettings.class);
additionalArgsOptionsField.attachLabel(additionalArgsLabel);
@@ -87,6 +91,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
public boolean isModified() {
return ComparingUtils.isModified(generateNoWarningsCheckBox, commonCompilerArguments.suppressWarnings) ||
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
ComparingUtils.isModified(incrementalCompilationCheckBox, compilerWorkspaceSettings.getIncrementalCompilationEnabled()) ||
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix);
@@ -96,6 +103,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
public void apply() throws ConfigurationException {
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText());
compilerWorkspaceSettings.setIncrementalCompilationEnabled(incrementalCompilationCheckBox.isSelected());
k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected();
k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true);
k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
@@ -105,6 +115,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
public void reset() {
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
incrementalCompilationCheckBox.setSelected(compilerWorkspaceSettings.getIncrementalCompilationEnabled());
generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap);
outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix);
outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix);
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.plugin.compiler.configuration
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.util.xmlb.XmlSerializerUtil
import com.intellij.compiler.CompilerWorkspaceConfiguration
import com.intellij.openapi.components.StoragePathMacros
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
State(
name = "KotlinCompilerWorkspaceSettings",
storages = array(
Storage(file = StoragePathMacros.WORKSPACE_FILE)
)
)
public class KotlinCompilerWorkspaceSettings() : PersistentStateComponent<KotlinCompilerWorkspaceSettings> {
public var incrementalCompilationEnabled: Boolean = false
override fun getState(): KotlinCompilerWorkspaceSettings {
return this
}
override fun loadState(state: KotlinCompilerWorkspaceSettings?) {
XmlSerializerUtil.copyBean(state!!, this)
}
}