Project Settings: Expose JVM target setting in IntelliJ IDEA plugin compiler configuration UI

#KT-13811 Fixed
This commit is contained in:
Alexey Sedunov
2016-11-22 11:48:15 +03:00
parent 740f769487
commit 21c6e97731
4 changed files with 57 additions and 5 deletions
+2
View File
@@ -326,6 +326,8 @@ These artifacts include extensions for the types available in the latter JDKs, s
### IDE
- [`KT-13811`](https://youtrack.jetbrains.com/issue/KT-13811) Expose JVM target setting in IntelliJ IDEA plugin compiler configuration UI
#### Intention actions, inspections and quickfixes
- [`KT-14569`](https://youtrack.jetbrains.com/issue/KT-14569) Convert Property to Function Intention: Search occurrences using progress dialog
@@ -92,7 +92,7 @@
</component>
</children>
</grid>
<grid id="2f977" binding="k2jvmPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="2f977" binding="k2jvmPanel" layout-manager="GridLayoutManager" row-count="2" 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="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"/>
@@ -105,14 +105,30 @@
</clientProperties>
<border type="etched" title-resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" title-key="kotlin.compiler.jvm.option.panel.title"/>
<children>
<component id="9131b" class="javax.swing.JLabel">
<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">
<preferred-size width="201" height="16"/>
</grid>
</constraints>
<properties>
<text value="Target &amp;JVM Version"/>
</properties>
</component>
<component id="d8f92" class="javax.swing.JCheckBox" binding="enablePreciseIncrementalCheckBox">
<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="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>
<properties>
<text value="Enable precise incremental compilation"/>
</properties>
</component>
<component id="769be" class="javax.swing.JComboBox" binding="jvmVersionComboBox">
<constraints>
<grid row="1" 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>
<properties/>
</component>
</children>
</grid>
<grid id="98e8a" binding="k2jsPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -34,8 +34,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants;
import org.jetbrains.kotlin.config.CompilerSettings;
import org.jetbrains.kotlin.config.JvmTarget;
import org.jetbrains.kotlin.config.TargetPlatformKind;
import org.jetbrains.kotlin.idea.KotlinBundle;
import org.jetbrains.kotlin.idea.PluginStartupComponent;
@@ -50,6 +52,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
private static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<String, String>();
private final CommonCompilerArguments commonCompilerArguments;
private final K2JSCompilerArguments k2jsCompilerArguments;
private final K2JVMCompilerArguments k2jvmCompilerArguments;
private final CompilerSettings compilerSettings;
@Nullable
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
@@ -75,6 +78,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
private JLabel scriptTemplatesClasspathLabel;
private JPanel k2jvmPanel;
private JPanel k2jsPanel;
private JComboBox jvmVersionComboBox;
static {
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, "Plain (put to global scope)");
@@ -88,13 +92,15 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
CommonCompilerArguments commonCompilerArguments,
K2JSCompilerArguments k2jsCompilerArguments,
CompilerSettings compilerSettings,
@Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings
@Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings,
@Nullable K2JVMCompilerArguments k2jvmCompilerArguments
) {
this.project = project;
this.commonCompilerArguments = commonCompilerArguments;
this.k2jsCompilerArguments = k2jsCompilerArguments;
this.compilerSettings = compilerSettings;
this.compilerWorkspaceSettings = compilerWorkspaceSettings;
this.k2jvmCompilerArguments = k2jvmCompilerArguments;
additionalArgsOptionsField.attachLabel(additionalArgsLabel);
@@ -113,6 +119,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
});
fillModuleKindList();
fillJvmVersionList();
if (compilerWorkspaceSettings == null) {
keepAliveCheckBox.setVisible(false);
@@ -120,6 +127,13 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
}
}
@SuppressWarnings("unchecked")
private void fillJvmVersionList() {
for (TargetPlatformKind.Jvm jvm : TargetPlatformKind.Jvm.Companion.getJVM_PLATFORMS()) {
jvmVersionComboBox.addItem(jvm.getVersion().getDescription());
}
}
public void setTargetPlatform(@Nullable TargetPlatformKind<?> targetPlatform) {
k2jsPanel.setVisible(TargetPlatformKind.JavaScript.INSTANCE.equals(targetPlatform));
}
@@ -130,7 +144,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
KotlinCommonCompilerArgumentsHolder.getInstance(project).getSettings(),
Kotlin2JsCompilerArgumentsHolder.getInstance(project).getSettings(),
KotlinCompilerSettings.getInstance(project).getSettings(),
ServiceManager.getService(project, KotlinCompilerWorkspaceSettings.class));
ServiceManager.getService(project, KotlinCompilerWorkspaceSettings.class),
Kotlin2JvmCompilerArgumentsHolder.getInstance(project).getSettings());
}
@SuppressWarnings("unchecked")
@@ -187,7 +202,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix) ||
!getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
!getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind)) ||
(k2jvmCompilerArguments != null && !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget)));
}
@NotNull
@@ -195,6 +211,11 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
return getModuleKindOrDefault((String) moduleKindComboBox.getSelectedItem());
}
@NotNull
private String getSelectedJvmVersion() {
return getJvmVersionOrDefault((String) jvmVersionComboBox.getSelectedItem());
}
@Override
public void apply() throws ConfigurationException {
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
@@ -219,6 +240,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
k2jsCompilerArguments.moduleKind = getSelectedModuleKind();
if (k2jvmCompilerArguments != null) {
k2jvmCompilerArguments.jvmTarget = getSelectedJvmVersion();
}
BuildManager.getInstance().clearState(project);
}
@@ -230,6 +255,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
return moduleKindId;
}
private static String getJvmVersionOrDefault(@Nullable String jvmVersion) {
return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription();
}
@Override
public void reset() {
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
@@ -249,6 +278,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix);
moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
if (k2jvmCompilerArguments != null) {
jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget));
}
}
@Override
@@ -30,6 +30,7 @@ class KotlinFacetEditorCompilerTab(
compilerInfo.commonCompilerArguments,
compilerInfo.k2jsCompilerArguments,
compilerInfo.compilerSettings,
null,
null
)