Project Settings: Expose language version setting in IntelliJ IDEA plugin compiler configuration UI
#KT-12410 Fixed
This commit is contained in:
@@ -327,6 +327,7 @@ 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
|
||||
- [`KT-12410`](https://youtrack.jetbrains.com/issue/KT-12410) Expose language version setting in IntelliJ IDEA plugin compiler configuration UI
|
||||
|
||||
#### Intention actions, inspections and quickfixes
|
||||
|
||||
|
||||
+34
-8
@@ -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="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27e96" layout-manager="GridLayoutManager" row-count="6" 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="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>
|
||||
<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="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"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -50,7 +50,7 @@
|
||||
</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"/>
|
||||
<grid row="3" 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="3" 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="4" 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="3" 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="4" 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="4" 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="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"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="644d9"/>
|
||||
@@ -84,12 +84,38 @@
|
||||
</component>
|
||||
<component id="644d9" class="javax.swing.JTextField" binding="scriptTemplatesClasspathField">
|
||||
<constraints>
|
||||
<grid row="4" 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="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">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="a9492" binding="languageVersionPanel" 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="1" 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="f4063" 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="&Language Version"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d931b" class="javax.swing.JComboBox" binding="languageVersionComboBox">
|
||||
<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">
|
||||
|
||||
+37
-2
@@ -38,6 +38,7 @@ 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.LanguageVersion;
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind;
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle;
|
||||
import org.jetbrains.kotlin.idea.PluginStartupComponent;
|
||||
@@ -57,6 +58,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
@Nullable
|
||||
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
|
||||
private final Project project;
|
||||
private final boolean showLanguageVersion;
|
||||
private JPanel contentPane;
|
||||
private JCheckBox generateNoWarningsCheckBox;
|
||||
private RawCommandLineEditor additionalArgsOptionsField;
|
||||
@@ -79,6 +81,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
private JPanel k2jvmPanel;
|
||||
private JPanel k2jsPanel;
|
||||
private JComboBox jvmVersionComboBox;
|
||||
private JComboBox languageVersionComboBox;
|
||||
private JPanel languageVersionPanel;
|
||||
|
||||
static {
|
||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, "Plain (put to global scope)");
|
||||
@@ -93,7 +97,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
K2JSCompilerArguments k2jsCompilerArguments,
|
||||
CompilerSettings compilerSettings,
|
||||
@Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings,
|
||||
@Nullable K2JVMCompilerArguments k2jvmCompilerArguments
|
||||
@Nullable K2JVMCompilerArguments k2jvmCompilerArguments,
|
||||
boolean showLanguageVersion
|
||||
) {
|
||||
this.project = project;
|
||||
this.commonCompilerArguments = commonCompilerArguments;
|
||||
@@ -101,6 +106,11 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
this.compilerSettings = compilerSettings;
|
||||
this.compilerWorkspaceSettings = compilerWorkspaceSettings;
|
||||
this.k2jvmCompilerArguments = k2jvmCompilerArguments;
|
||||
this.showLanguageVersion = showLanguageVersion;
|
||||
|
||||
if (!showLanguageVersion) {
|
||||
languageVersionPanel.setVisible(false);
|
||||
}
|
||||
|
||||
additionalArgsOptionsField.attachLabel(additionalArgsLabel);
|
||||
|
||||
@@ -120,6 +130,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
|
||||
fillModuleKindList();
|
||||
fillJvmVersionList();
|
||||
fillLanguageVersionList();
|
||||
|
||||
if (compilerWorkspaceSettings == null) {
|
||||
keepAliveCheckBox.setVisible(false);
|
||||
@@ -134,6 +145,13 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fillLanguageVersionList() {
|
||||
for (LanguageVersion version : LanguageVersion.values()) {
|
||||
languageVersionComboBox.addItem(version.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
public void setTargetPlatform(@Nullable TargetPlatformKind<?> targetPlatform) {
|
||||
k2jsPanel.setVisible(TargetPlatformKind.JavaScript.INSTANCE.equals(targetPlatform));
|
||||
}
|
||||
@@ -145,7 +163,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
Kotlin2JsCompilerArgumentsHolder.getInstance(project).getSettings(),
|
||||
KotlinCompilerSettings.getInstance(project).getSettings(),
|
||||
ServiceManager.getService(project, KotlinCompilerWorkspaceSettings.class),
|
||||
Kotlin2JvmCompilerArgumentsHolder.getInstance(project).getSettings());
|
||||
Kotlin2JvmCompilerArgumentsHolder.getInstance(project).getSettings(),
|
||||
true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -189,6 +208,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return ComparingUtils.isModified(generateNoWarningsCheckBox, commonCompilerArguments.suppressWarnings) ||
|
||||
(showLanguageVersion && !getSelectedLanguageVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion))) ||
|
||||
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
|
||||
ComparingUtils.isModified(scriptTemplatesField, compilerSettings.getScriptTemplates()) ||
|
||||
ComparingUtils.isModified(scriptTemplatesClasspathField, compilerSettings.getScriptTemplatesClasspath()) ||
|
||||
@@ -216,9 +236,17 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
return getJvmVersionOrDefault((String) jvmVersionComboBox.getSelectedItem());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getSelectedLanguageVersion() {
|
||||
return getLanguageVersionOrDefault((String) languageVersionComboBox.getSelectedItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
|
||||
if (showLanguageVersion) {
|
||||
commonCompilerArguments.languageVersion = getSelectedLanguageVersion();
|
||||
}
|
||||
compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText());
|
||||
compilerSettings.setScriptTemplates(scriptTemplatesField.getText());
|
||||
compilerSettings.setScriptTemplatesClasspath(scriptTemplatesClasspathField.getText());
|
||||
@@ -259,9 +287,16 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription();
|
||||
}
|
||||
|
||||
private static String getLanguageVersionOrDefault(@Nullable String languageVersion) {
|
||||
return languageVersion != null ? languageVersion : LanguageVersion.LATEST.getVersionString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
|
||||
if (showLanguageVersion) {
|
||||
languageVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion));
|
||||
}
|
||||
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
|
||||
scriptTemplatesField.setText(compilerSettings.getScriptTemplates());
|
||||
scriptTemplatesClasspathField.setText(compilerSettings.getScriptTemplatesClasspath());
|
||||
|
||||
@@ -31,7 +31,8 @@ class KotlinFacetEditorCompilerTab(
|
||||
compilerInfo.k2jsCompilerArguments,
|
||||
compilerInfo.compilerSettings,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
false
|
||||
)
|
||||
|
||||
override fun apply() = compilerConfigurable.apply()
|
||||
|
||||
Reference in New Issue
Block a user