Project Settings: Expose API version setting in Kotlin compiler configuration UI
This commit is contained in:
+35
-9
@@ -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="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27e96" layout-manager="GridLayoutManager" row-count="8" 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"/>
|
||||
@@ -32,7 +32,7 @@
|
||||
</component>
|
||||
<component id="ba279" class="javax.swing.JLabel" binding="additionalArgsLabel">
|
||||
<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>
|
||||
<properties>
|
||||
<text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.option.additional.command.line.parameters"/>
|
||||
@@ -40,7 +40,7 @@
|
||||
</component>
|
||||
<component id="7a827" class="com.intellij.ui.RawCommandLineEditor" binding="additionalArgsOptionsField">
|
||||
<constraints>
|
||||
<grid row="3" 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="4" 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"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -50,7 +50,7 @@
|
||||
</component>
|
||||
<component id="c45a6" class="javax.swing.JCheckBox" binding="keepAliveCheckBox">
|
||||
<constraints>
|
||||
<grid row="4" 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="5" 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"/>
|
||||
@@ -58,7 +58,7 @@
|
||||
</component>
|
||||
<component id="ae60b" class="javax.swing.JLabel" binding="scriptTemplatesLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="71c3f"/>
|
||||
@@ -67,7 +67,7 @@
|
||||
</component>
|
||||
<component id="71c3f" class="javax.swing.JTextField" binding="scriptTemplatesField">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="1" use-parent-layout="false">
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="1" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -75,7 +75,7 @@
|
||||
</component>
|
||||
<component id="56390" class="javax.swing.JLabel" binding="scriptTemplatesClasspathLabel">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" 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="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="644d9"/>
|
||||
@@ -84,7 +84,7 @@
|
||||
</component>
|
||||
<component id="644d9" class="javax.swing.JTextField" binding="scriptTemplatesClasspathField">
|
||||
<constraints>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="1" 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="1" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -119,7 +119,7 @@
|
||||
<grid id="6b551" layout-manager="GridLayoutManager" row-count="1" 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="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -142,6 +142,32 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="d8cd" binding="apiVersionPanel" layout-manager="GridLayoutManager" row-count="1" 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="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="5158" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" 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="AP&I Version"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ab3e4" class="javax.swing.JComboBox" binding="apiVersionComboBox">
|
||||
<constraints>
|
||||
<grid row="0" 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>
|
||||
</children>
|
||||
</grid>
|
||||
<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">
|
||||
|
||||
+15
-2
@@ -94,6 +94,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
private JComboBox languageVersionComboBox;
|
||||
private JPanel languageVersionPanel;
|
||||
private JComboBox coroutineSupportComboBox;
|
||||
private JPanel apiVersionPanel;
|
||||
private JComboBox apiVersionComboBox;
|
||||
|
||||
public KotlinCompilerConfigurableTab(
|
||||
Project project,
|
||||
@@ -114,6 +116,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
|
||||
if (!isProjectSettings) {
|
||||
languageVersionPanel.setVisible(false);
|
||||
apiVersionPanel.setVisible(false);
|
||||
}
|
||||
|
||||
additionalArgsOptionsField.attachLabel(additionalArgsLabel);
|
||||
@@ -134,7 +137,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
|
||||
fillModuleKindList();
|
||||
fillJvmVersionList();
|
||||
fillLanguageVersionList();
|
||||
fillLanguageAndAPIVersionList();
|
||||
fillCoroutineSupportList();
|
||||
|
||||
if (compilerWorkspaceSettings == null) {
|
||||
@@ -201,9 +204,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fillLanguageVersionList() {
|
||||
private void fillLanguageAndAPIVersionList() {
|
||||
for (LanguageVersion version : LanguageVersion.values()) {
|
||||
languageVersionComboBox.addItem(version.getDescription());
|
||||
apiVersionComboBox.addItem(version.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,6 +258,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
public boolean isModified() {
|
||||
return ComparingUtils.isModified(generateNoWarningsCheckBox, commonCompilerArguments.suppressWarnings) ||
|
||||
(isProjectSettings && !getSelectedLanguageVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion))) ||
|
||||
(isProjectSettings && !getSelectedAPIVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.apiVersion))) ||
|
||||
!coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments)) ||
|
||||
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.additionalArguments) ||
|
||||
ComparingUtils.isModified(scriptTemplatesField, compilerSettings.scriptTemplates) ||
|
||||
@@ -287,14 +292,21 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
return getLanguageVersionOrDefault((String) languageVersionComboBox.getSelectedItem());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getSelectedAPIVersion() {
|
||||
return getLanguageVersionOrDefault((String) apiVersionComboBox.getSelectedItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
|
||||
if (isProjectSettings) {
|
||||
boolean shouldInvalidateCaches =
|
||||
commonCompilerArguments.languageVersion != getSelectedLanguageVersion() ||
|
||||
commonCompilerArguments.apiVersion != getSelectedAPIVersion() ||
|
||||
!coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments));
|
||||
commonCompilerArguments.languageVersion = getSelectedLanguageVersion();
|
||||
commonCompilerArguments.apiVersion = getSelectedAPIVersion();
|
||||
if (shouldInvalidateCaches) {
|
||||
ApplicationUtilsKt.runWriteAction(
|
||||
new Function0<Object>() {
|
||||
@@ -344,6 +356,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
|
||||
if (isProjectSettings) {
|
||||
languageVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion));
|
||||
apiVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.apiVersion));
|
||||
}
|
||||
coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArguments(commonCompilerArguments));
|
||||
additionalArgsOptionsField.setText(compilerSettings.additionalArguments);
|
||||
|
||||
Reference in New Issue
Block a user