Project Settings: Expose JVM target setting in IntelliJ IDEA plugin compiler configuration UI
#KT-13811 Fixed
This commit is contained in:
@@ -326,6 +326,8 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
|
|
||||||
### IDE
|
### 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
|
#### Intention actions, inspections and quickfixes
|
||||||
|
|
||||||
- [`KT-14569`](https://youtrack.jetbrains.com/issue/KT-14569) Convert Property to Function Intention: Search occurrences using progress dialog
|
- [`KT-14569`](https://youtrack.jetbrains.com/issue/KT-14569) Convert Property to Function Intention: Search occurrences using progress dialog
|
||||||
|
|||||||
+18
-2
@@ -92,7 +92,7 @@
|
|||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</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"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<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"/>
|
<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>
|
</clientProperties>
|
||||||
<border type="etched" title-resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" title-key="kotlin.compiler.jvm.option.panel.title"/>
|
<border type="etched" title-resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" title-key="kotlin.compiler.jvm.option.panel.title"/>
|
||||||
<children>
|
<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 &JVM Version"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
<component id="d8f92" class="javax.swing.JCheckBox" binding="enablePreciseIncrementalCheckBox">
|
<component id="d8f92" class="javax.swing.JCheckBox" binding="enablePreciseIncrementalCheckBox">
|
||||||
<constraints>
|
<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>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Enable precise incremental compilation"/>
|
<text value="Enable precise incremental compilation"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</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>
|
</children>
|
||||||
</grid>
|
</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">
|
<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">
|
||||||
|
|||||||
+36
-3
@@ -34,8 +34,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
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.cli.common.arguments.K2JsArgumentConstants;
|
||||||
import org.jetbrains.kotlin.config.CompilerSettings;
|
import org.jetbrains.kotlin.config.CompilerSettings;
|
||||||
|
import org.jetbrains.kotlin.config.JvmTarget;
|
||||||
import org.jetbrains.kotlin.config.TargetPlatformKind;
|
import org.jetbrains.kotlin.config.TargetPlatformKind;
|
||||||
import org.jetbrains.kotlin.idea.KotlinBundle;
|
import org.jetbrains.kotlin.idea.KotlinBundle;
|
||||||
import org.jetbrains.kotlin.idea.PluginStartupComponent;
|
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 static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<String, String>();
|
||||||
private final CommonCompilerArguments commonCompilerArguments;
|
private final CommonCompilerArguments commonCompilerArguments;
|
||||||
private final K2JSCompilerArguments k2jsCompilerArguments;
|
private final K2JSCompilerArguments k2jsCompilerArguments;
|
||||||
|
private final K2JVMCompilerArguments k2jvmCompilerArguments;
|
||||||
private final CompilerSettings compilerSettings;
|
private final CompilerSettings compilerSettings;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
|
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
|
||||||
@@ -75,6 +78,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
private JLabel scriptTemplatesClasspathLabel;
|
private JLabel scriptTemplatesClasspathLabel;
|
||||||
private JPanel k2jvmPanel;
|
private JPanel k2jvmPanel;
|
||||||
private JPanel k2jsPanel;
|
private JPanel k2jsPanel;
|
||||||
|
private JComboBox jvmVersionComboBox;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, "Plain (put to global scope)");
|
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, "Plain (put to global scope)");
|
||||||
@@ -88,13 +92,15 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
CommonCompilerArguments commonCompilerArguments,
|
CommonCompilerArguments commonCompilerArguments,
|
||||||
K2JSCompilerArguments k2jsCompilerArguments,
|
K2JSCompilerArguments k2jsCompilerArguments,
|
||||||
CompilerSettings compilerSettings,
|
CompilerSettings compilerSettings,
|
||||||
@Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings
|
@Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings,
|
||||||
|
@Nullable K2JVMCompilerArguments k2jvmCompilerArguments
|
||||||
) {
|
) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.commonCompilerArguments = commonCompilerArguments;
|
this.commonCompilerArguments = commonCompilerArguments;
|
||||||
this.k2jsCompilerArguments = k2jsCompilerArguments;
|
this.k2jsCompilerArguments = k2jsCompilerArguments;
|
||||||
this.compilerSettings = compilerSettings;
|
this.compilerSettings = compilerSettings;
|
||||||
this.compilerWorkspaceSettings = compilerWorkspaceSettings;
|
this.compilerWorkspaceSettings = compilerWorkspaceSettings;
|
||||||
|
this.k2jvmCompilerArguments = k2jvmCompilerArguments;
|
||||||
|
|
||||||
additionalArgsOptionsField.attachLabel(additionalArgsLabel);
|
additionalArgsOptionsField.attachLabel(additionalArgsLabel);
|
||||||
|
|
||||||
@@ -113,6 +119,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
});
|
});
|
||||||
|
|
||||||
fillModuleKindList();
|
fillModuleKindList();
|
||||||
|
fillJvmVersionList();
|
||||||
|
|
||||||
if (compilerWorkspaceSettings == null) {
|
if (compilerWorkspaceSettings == null) {
|
||||||
keepAliveCheckBox.setVisible(false);
|
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) {
|
public void setTargetPlatform(@Nullable TargetPlatformKind<?> targetPlatform) {
|
||||||
k2jsPanel.setVisible(TargetPlatformKind.JavaScript.INSTANCE.equals(targetPlatform));
|
k2jsPanel.setVisible(TargetPlatformKind.JavaScript.INSTANCE.equals(targetPlatform));
|
||||||
}
|
}
|
||||||
@@ -130,7 +144,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
KotlinCommonCompilerArgumentsHolder.getInstance(project).getSettings(),
|
KotlinCommonCompilerArgumentsHolder.getInstance(project).getSettings(),
|
||||||
Kotlin2JsCompilerArgumentsHolder.getInstance(project).getSettings(),
|
Kotlin2JsCompilerArgumentsHolder.getInstance(project).getSettings(),
|
||||||
KotlinCompilerSettings.getInstance(project).getSettings(),
|
KotlinCompilerSettings.getInstance(project).getSettings(),
|
||||||
ServiceManager.getService(project, KotlinCompilerWorkspaceSettings.class));
|
ServiceManager.getService(project, KotlinCompilerWorkspaceSettings.class),
|
||||||
|
Kotlin2JvmCompilerArgumentsHolder.getInstance(project).getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -187,7 +202,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
|
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
|
||||||
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
|
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
|
||||||
isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix) ||
|
isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix) ||
|
||||||
!getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
|
!getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind)) ||
|
||||||
|
(k2jvmCompilerArguments != null && !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -195,6 +211,11 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
return getModuleKindOrDefault((String) moduleKindComboBox.getSelectedItem());
|
return getModuleKindOrDefault((String) moduleKindComboBox.getSelectedItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String getSelectedJvmVersion() {
|
||||||
|
return getJvmVersionOrDefault((String) jvmVersionComboBox.getSelectedItem());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() throws ConfigurationException {
|
public void apply() throws ConfigurationException {
|
||||||
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
|
commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
|
||||||
@@ -219,6 +240,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
|
k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
|
||||||
k2jsCompilerArguments.moduleKind = getSelectedModuleKind();
|
k2jsCompilerArguments.moduleKind = getSelectedModuleKind();
|
||||||
|
|
||||||
|
if (k2jvmCompilerArguments != null) {
|
||||||
|
k2jvmCompilerArguments.jvmTarget = getSelectedJvmVersion();
|
||||||
|
}
|
||||||
|
|
||||||
BuildManager.getInstance().clearState(project);
|
BuildManager.getInstance().clearState(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +255,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
return moduleKindId;
|
return moduleKindId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getJvmVersionOrDefault(@Nullable String jvmVersion) {
|
||||||
|
return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
|
generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
|
||||||
@@ -249,6 +278,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix);
|
outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix);
|
||||||
|
|
||||||
moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
|
moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
|
||||||
|
|
||||||
|
if (k2jvmCompilerArguments != null) {
|
||||||
|
jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class KotlinFacetEditorCompilerTab(
|
|||||||
compilerInfo.commonCompilerArguments,
|
compilerInfo.commonCompilerArguments,
|
||||||
compilerInfo.k2jsCompilerArguments,
|
compilerInfo.k2jsCompilerArguments,
|
||||||
compilerInfo.compilerSettings,
|
compilerInfo.compilerSettings,
|
||||||
|
null,
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user