Configuration: Support selection of "Latest stable" version vs specific one
#KT-21229 Fixed
This commit is contained in:
+7
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.common.arguments
|
package org.jetbrains.kotlin.cli.common.arguments
|
||||||
|
|
||||||
|
import com.intellij.util.xmlb.annotations.Transient
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.config.AnalysisFlag
|
import org.jetbrains.kotlin.config.AnalysisFlag
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -32,6 +33,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
const val ENABLE = "enable"
|
const val ENABLE = "enable"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get:Transient
|
||||||
|
var autoAdvanceLanguageVersion: Boolean by FreezableVar(true)
|
||||||
|
|
||||||
@GradleOption(DefaultValues.LanguageVersions::class)
|
@GradleOption(DefaultValues.LanguageVersions::class)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-language-version",
|
value = "-language-version",
|
||||||
@@ -40,6 +44,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
)
|
)
|
||||||
var languageVersion: String? by FreezableVar(null)
|
var languageVersion: String? by FreezableVar(null)
|
||||||
|
|
||||||
|
@get:Transient
|
||||||
|
var autoAdvanceApiVersion: Boolean by FreezableVar(true)
|
||||||
|
|
||||||
@GradleOption(DefaultValues.LanguageVersions::class)
|
@GradleOption(DefaultValues.LanguageVersions::class)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-api-version",
|
value = "-api-version",
|
||||||
|
|||||||
+6
-14
@@ -21,45 +21,37 @@ import com.intellij.openapi.project.Project
|
|||||||
import com.intellij.util.text.VersionComparatorUtil
|
import com.intellij.util.text.VersionComparatorUtil
|
||||||
import org.jdom.Element
|
import org.jdom.Element
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
|
||||||
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION
|
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION
|
||||||
import org.jetbrains.kotlin.config.getOption
|
import org.jetbrains.kotlin.config.detectVersionAutoAdvance
|
||||||
|
import org.jetbrains.kotlin.config.dropVersionsIfNecessary
|
||||||
|
|
||||||
@State(name = KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION,
|
@State(name = KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION,
|
||||||
storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE),
|
storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||||
Storage(file = BaseKotlinCompilerSettings.KOTLIN_COMPILER_SETTINGS_PATH,
|
Storage(file = BaseKotlinCompilerSettings.KOTLIN_COMPILER_SETTINGS_PATH,
|
||||||
scheme = StorageScheme.DIRECTORY_BASED)))
|
scheme = StorageScheme.DIRECTORY_BASED)))
|
||||||
class KotlinCommonCompilerArgumentsHolder(project: Project) : BaseKotlinCompilerSettings<CommonCompilerArguments>(project) {
|
class KotlinCommonCompilerArgumentsHolder(project: Project) : BaseKotlinCompilerSettings<CommonCompilerArguments>(project) {
|
||||||
private fun Element.dropElementIfDefault() {
|
|
||||||
if (DEFAULT_LANGUAGE_VERSION == getAttribute("value")?.value) {
|
|
||||||
detach()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getState(): Element {
|
override fun getState(): Element {
|
||||||
return super.getState().apply {
|
return super.getState().apply {
|
||||||
// Do not serialize language/api version if they correspond to the default language version
|
dropVersionsIfNecessary(settings)
|
||||||
getOption("languageVersion")?.dropElementIfDefault()
|
|
||||||
getOption("apiVersion")?.dropElementIfDefault()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadState(state: Element) {
|
override fun loadState(state: Element) {
|
||||||
super.loadState(state)
|
super.loadState(state)
|
||||||
|
|
||||||
// To fix earlier configurations with incorrect combination of language and API version
|
|
||||||
update {
|
update {
|
||||||
|
// To fix earlier configurations with incorrect combination of language and API version
|
||||||
if (VersionComparatorUtil.compare(languageVersion, apiVersion) < 0) {
|
if (VersionComparatorUtil.compare(languageVersion, apiVersion) < 0) {
|
||||||
apiVersion = languageVersion
|
apiVersion = languageVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detectVersionAutoAdvance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createSettings() = CommonCompilerArguments.DummyImpl()
|
override fun createSettings() = CommonCompilerArguments.DummyImpl()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val DEFAULT_LANGUAGE_VERSION = LanguageVersion.LATEST_STABLE.versionString
|
|
||||||
|
|
||||||
fun getInstance(project: Project) =
|
fun getInstance(project: Project) =
|
||||||
ServiceManager.getService<KotlinCommonCompilerArgumentsHolder>(project, KotlinCommonCompilerArgumentsHolder::class.java)!!
|
ServiceManager.getService<KotlinCommonCompilerArgumentsHolder>(project, KotlinCommonCompilerArgumentsHolder::class.java)!!
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,48 @@ object CoroutineSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sealed class VersionView : DescriptionAware {
|
||||||
|
abstract val version: LanguageVersion
|
||||||
|
|
||||||
|
object LatestStable : VersionView() {
|
||||||
|
override val version: LanguageVersion = LanguageVersion.LATEST_STABLE
|
||||||
|
|
||||||
|
override val description: String
|
||||||
|
get() = "Latest stable (${version.versionString})"
|
||||||
|
}
|
||||||
|
|
||||||
|
class Specific(override val version: LanguageVersion) : VersionView() {
|
||||||
|
override val description: String
|
||||||
|
get() = version.description
|
||||||
|
|
||||||
|
override fun equals(other: Any?) = other is Specific && version == other.version
|
||||||
|
|
||||||
|
override fun hashCode() = version.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun deserialize(value: String?, isAutoAdvance: Boolean): VersionView {
|
||||||
|
if (isAutoAdvance) return VersionView.LatestStable
|
||||||
|
val languageVersion = LanguageVersion.fromVersionString(value)
|
||||||
|
return if (languageVersion != null) VersionView.Specific(languageVersion) else VersionView.LatestStable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CommonCompilerArguments.languageVersionView: VersionView
|
||||||
|
get() = VersionView.deserialize(languageVersion, autoAdvanceLanguageVersion)
|
||||||
|
set(value) {
|
||||||
|
languageVersion = value.version.versionString
|
||||||
|
autoAdvanceLanguageVersion = value == VersionView.LatestStable
|
||||||
|
}
|
||||||
|
|
||||||
|
var CommonCompilerArguments.apiVersionView: VersionView
|
||||||
|
get() = VersionView.deserialize(apiVersion, autoAdvanceApiVersion)
|
||||||
|
set(value) {
|
||||||
|
apiVersion = value.version.versionString
|
||||||
|
autoAdvanceApiVersion = value == VersionView.LatestStable
|
||||||
|
}
|
||||||
|
|
||||||
class KotlinFacetSettings {
|
class KotlinFacetSettings {
|
||||||
companion object {
|
companion object {
|
||||||
// Increment this when making serialization-incompatible changes to configuration data
|
// Increment this when making serialization-incompatible changes to configuration data
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ private fun readV1Config(element: Element): KotlinFacetSettings {
|
|||||||
compilerArguments.apiVersion = apiLevel
|
compilerArguments.apiVersion = apiLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compilerArguments.detectVersionAutoAdvance()
|
||||||
|
|
||||||
if (useProjectSettings != null) {
|
if (useProjectSettings != null) {
|
||||||
this.useProjectSettings = useProjectSettings
|
this.useProjectSettings = useProjectSettings
|
||||||
}
|
}
|
||||||
@@ -106,6 +108,7 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings {
|
|||||||
element.getChild("compilerArguments")?.let {
|
element.getChild("compilerArguments")?.let {
|
||||||
compilerArguments = platformKind.createCompilerArguments { freeArgs = ArrayList() }
|
compilerArguments = platformKind.createCompilerArguments { freeArgs = ArrayList() }
|
||||||
XmlSerializer.deserializeInto(compilerArguments!!, it)
|
XmlSerializer.deserializeInto(compilerArguments!!, it)
|
||||||
|
compilerArguments!!.detectVersionAutoAdvance()
|
||||||
}
|
}
|
||||||
testOutputPath = element.getChild("testOutputPath")?.let {
|
testOutputPath = element.getChild("testOutputPath")?.let {
|
||||||
PathUtil.toSystemDependentName((it.content.firstOrNull() as? Text)?.textTrim)
|
PathUtil.toSystemDependentName((it.content.firstOrNull() as? Text)?.textTrim)
|
||||||
@@ -214,8 +217,8 @@ private fun Element.restoreNormalOrdering(bean: Any) {
|
|||||||
.forEachIndexed { index, element -> elementsToReorder[index] = element.clone() }
|
.forEachIndexed { index, element -> elementsToReorder[index] = element.clone() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildChildElement(element: Element, tag: String, bean: Any, filter: SerializationFilter) {
|
private fun buildChildElement(element: Element, tag: String, bean: Any, filter: SerializationFilter): Element {
|
||||||
Element(tag).apply {
|
return Element(tag).apply {
|
||||||
XmlSerializer.serializeInto(bean, this, filter)
|
XmlSerializer.serializeInto(bean, this, filter)
|
||||||
restoreNormalOrdering(bean)
|
restoreNormalOrdering(bean)
|
||||||
element.addContent(this)
|
element.addContent(this)
|
||||||
@@ -245,7 +248,24 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) {
|
|||||||
}
|
}
|
||||||
compilerArguments?.let { copyBean(it) }?.let {
|
compilerArguments?.let { copyBean(it) }?.let {
|
||||||
it.convertPathsToSystemIndependent()
|
it.convertPathsToSystemIndependent()
|
||||||
buildChildElement(element, "compilerArguments", it, filter)
|
val compilerArgumentsXml = buildChildElement(element, "compilerArguments", it, filter)
|
||||||
|
compilerArgumentsXml.dropVersionsIfNecessary(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CommonCompilerArguments.detectVersionAutoAdvance() {
|
||||||
|
autoAdvanceLanguageVersion = languageVersion == null
|
||||||
|
autoAdvanceApiVersion = apiVersion == null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Element.dropVersionsIfNecessary(settings: CommonCompilerArguments) {
|
||||||
|
// Do not serialize language/api version if they correspond to the default language version
|
||||||
|
if (settings.autoAdvanceLanguageVersion) {
|
||||||
|
getOption("languageVersion")?.detach()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.autoAdvanceApiVersion) {
|
||||||
|
getOption("apiVersion")?.detach()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-37
@@ -58,10 +58,7 @@ import org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Configurable.NoScroll{
|
public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Configurable.NoScroll{
|
||||||
private static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<>();
|
private static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<>();
|
||||||
@@ -111,9 +108,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
private JPanel k2jvmPanel;
|
private JPanel k2jvmPanel;
|
||||||
private JPanel k2jsPanel;
|
private JPanel k2jsPanel;
|
||||||
private JComboBox jvmVersionComboBox;
|
private JComboBox jvmVersionComboBox;
|
||||||
private JComboBox languageVersionComboBox;
|
private JComboBox<VersionView> languageVersionComboBox;
|
||||||
private JComboBox coroutineSupportComboBox;
|
private JComboBox coroutineSupportComboBox;
|
||||||
private JComboBox apiVersionComboBox;
|
private JComboBox<VersionView> apiVersionComboBox;
|
||||||
private JPanel scriptPanel;
|
private JPanel scriptPanel;
|
||||||
private JLabel labelForOutputPrefixFile;
|
private JLabel labelForOutputPrefixFile;
|
||||||
private JLabel labelForOutputPostfixFile;
|
private JLabel labelForOutputPostfixFile;
|
||||||
@@ -145,7 +142,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
restrictAPIVersions(getSelectedLanguageVersion());
|
restrictAPIVersions(getSelectedLanguageVersionView().getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -295,15 +292,6 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription();
|
return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LanguageVersion getLanguageVersionOrDefault(@Nullable String languageVersion) {
|
|
||||||
LanguageVersion version = LanguageVersion.fromVersionString(languageVersion);
|
|
||||||
return version != null ? version : LanguageVersion.LATEST_STABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ApiVersion getApiVersionOrDefault(@Nullable String apiVersion) {
|
|
||||||
return apiVersion != null ? ApiVersion.Companion.parse(apiVersion) : ApiVersion.LATEST_STABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setupFileChooser(
|
private static void setupFileChooser(
|
||||||
@NotNull JLabel label,
|
@NotNull JLabel label,
|
||||||
@NotNull TextFieldWithBrowseButton fileChooser,
|
@NotNull TextFieldWithBrowseButton fileChooser,
|
||||||
@@ -328,15 +316,21 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLessOrEqual(LanguageVersion version, LanguageVersion upperBound) {
|
||||||
|
return VersionComparatorUtil.compare(version.getVersionString(), upperBound.getVersionString()) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void restrictAPIVersions(LanguageVersion upperBound) {
|
public void restrictAPIVersions(LanguageVersion upperBound) {
|
||||||
ApiVersion selectedAPIVersion = getSelectedAPIVersion();
|
LanguageVersion selectedAPIVersion = getSelectedAPIVersionView().getVersion();
|
||||||
List<ApiVersion> permittedAPIVersions = ArraysKt.mapNotNull(
|
List<VersionView> permittedAPIVersions = new ArrayList<>(LanguageVersion.values().length + 1);
|
||||||
|
if (isLessOrEqual(VersionView.LatestStable.INSTANCE.getVersion(), upperBound)) {
|
||||||
|
permittedAPIVersions.add(VersionView.LatestStable.INSTANCE);
|
||||||
|
}
|
||||||
|
ArraysKt.mapNotNullTo(
|
||||||
LanguageVersion.values(),
|
LanguageVersion.values(),
|
||||||
version -> VersionComparatorUtil.compare(version.getVersionString(), upperBound.getVersionString()) <= 0 &&
|
permittedAPIVersions,
|
||||||
VersionComparatorUtil.compare(version.getVersionString(), upperBound.getVersionString()) <= 0
|
version -> isLessOrEqual(version, upperBound) ? new VersionView.Specific(version) : null
|
||||||
? ApiVersion.createByLanguageVersion(version)
|
|
||||||
: null
|
|
||||||
);
|
);
|
||||||
apiVersionComboBox.setModel(
|
apiVersionComboBox.setModel(
|
||||||
new DefaultComboBoxModel(permittedAPIVersions.toArray())
|
new DefaultComboBoxModel(permittedAPIVersions.toArray())
|
||||||
@@ -357,13 +351,17 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void fillLanguageAndAPIVersionList() {
|
private void fillLanguageAndAPIVersionList() {
|
||||||
|
languageVersionComboBox.addItem(VersionView.LatestStable.INSTANCE);
|
||||||
|
apiVersionComboBox.addItem(VersionView.LatestStable.INSTANCE);
|
||||||
|
|
||||||
for (LanguageVersion version : LanguageVersion.values()) {
|
for (LanguageVersion version : LanguageVersion.values()) {
|
||||||
if (!version.isStable() && !KotlinInternalMode.Instance.getEnabled()) {
|
if (!version.isStable() && !KotlinInternalMode.Instance.getEnabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
languageVersionComboBox.addItem(version);
|
VersionView.Specific specificVersion = new VersionView.Specific(version);
|
||||||
apiVersionComboBox.addItem(ApiVersion.createByLanguageVersion(version));
|
languageVersionComboBox.addItem(specificVersion);
|
||||||
|
apiVersionComboBox.addItem(specificVersion);
|
||||||
}
|
}
|
||||||
languageVersionComboBox.setRenderer(new DescriptionListCellRenderer());
|
languageVersionComboBox.setRenderer(new DescriptionListCellRenderer());
|
||||||
apiVersionComboBox.setRenderer(new DescriptionListCellRenderer());
|
apiVersionComboBox.setRenderer(new DescriptionListCellRenderer());
|
||||||
@@ -429,8 +427,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
@Override
|
@Override
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
return ComparingUtils.isModified(reportWarningsCheckBox, !commonCompilerArguments.getSuppressWarnings()) ||
|
return ComparingUtils.isModified(reportWarningsCheckBox, !commonCompilerArguments.getSuppressWarnings()) ||
|
||||||
!getSelectedLanguageVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.getLanguageVersion())) ||
|
!getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) ||
|
||||||
!getSelectedAPIVersion().equals(getApiVersionOrDefault(commonCompilerArguments.getApiVersion())) ||
|
!getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) ||
|
||||||
!coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments)) ||
|
!coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments)) ||
|
||||||
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
|
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
|
||||||
ComparingUtils.isModified(scriptTemplatesField, compilerSettings.getScriptTemplates()) ||
|
ComparingUtils.isModified(scriptTemplatesField, compilerSettings.getScriptTemplates()) ||
|
||||||
@@ -467,15 +465,15 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public LanguageVersion getSelectedLanguageVersion() {
|
public VersionView getSelectedLanguageVersionView() {
|
||||||
Object item = languageVersionComboBox.getSelectedItem();
|
Object item = languageVersionComboBox.getSelectedItem();
|
||||||
return item != null ? (LanguageVersion) item : LanguageVersion.LATEST_STABLE;
|
return item != null ? (VersionView) item : VersionView.LatestStable.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private ApiVersion getSelectedAPIVersion() {
|
private VersionView getSelectedAPIVersionView() {
|
||||||
Object item = apiVersionComboBox.getSelectedItem();
|
Object item = apiVersionComboBox.getSelectedItem();
|
||||||
return item != null ? (ApiVersion) item : ApiVersion.LATEST_STABLE;
|
return item != null ? (VersionView) item : VersionView.LatestStable.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyTo(
|
public void applyTo(
|
||||||
@@ -486,8 +484,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
) throws ConfigurationException {
|
) throws ConfigurationException {
|
||||||
if (isProjectSettings) {
|
if (isProjectSettings) {
|
||||||
boolean shouldInvalidateCaches =
|
boolean shouldInvalidateCaches =
|
||||||
commonCompilerArguments.getLanguageVersion() != getSelectedLanguageVersion().getVersionString() ||
|
!getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) ||
|
||||||
commonCompilerArguments.getApiVersion() != getSelectedAPIVersion().getVersionString() ||
|
!getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) ||
|
||||||
!coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments));
|
!coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments));
|
||||||
|
|
||||||
if (shouldInvalidateCaches) {
|
if (shouldInvalidateCaches) {
|
||||||
@@ -504,8 +502,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
commonCompilerArguments.setSuppressWarnings(!reportWarningsCheckBox.isSelected());
|
commonCompilerArguments.setSuppressWarnings(!reportWarningsCheckBox.isSelected());
|
||||||
commonCompilerArguments.setLanguageVersion(getSelectedLanguageVersion().getVersionString());
|
KotlinFacetSettingsKt.setLanguageVersionView(commonCompilerArguments, getSelectedLanguageVersionView());
|
||||||
commonCompilerArguments.setApiVersion(getSelectedAPIVersion().getVersionString());
|
KotlinFacetSettingsKt.setApiVersionView(commonCompilerArguments, getSelectedAPIVersionView());
|
||||||
|
|
||||||
switch ((LanguageFeature.State) coroutineSupportComboBox.getSelectedItem()) {
|
switch ((LanguageFeature.State) coroutineSupportComboBox.getSelectedItem()) {
|
||||||
case ENABLED:
|
case ENABLED:
|
||||||
@@ -564,9 +562,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
reportWarningsCheckBox.setSelected(!commonCompilerArguments.getSuppressWarnings());
|
reportWarningsCheckBox.setSelected(!commonCompilerArguments.getSuppressWarnings());
|
||||||
languageVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.getLanguageVersion()));
|
languageVersionComboBox.setSelectedItem(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments));
|
||||||
apiVersionComboBox.setSelectedItem(getApiVersionOrDefault(commonCompilerArguments.getApiVersion()));
|
restrictAPIVersions(getSelectedLanguageVersionView().getVersion());
|
||||||
restrictAPIVersions(getSelectedLanguageVersion());
|
apiVersionComboBox.setSelectedItem(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments));
|
||||||
coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArguments(commonCompilerArguments));
|
coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArguments(commonCompilerArguments));
|
||||||
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
|
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
|
||||||
scriptTemplatesField.setText(compilerSettings.getScriptTemplates());
|
scriptTemplatesField.setText(compilerSettings.getScriptTemplates());
|
||||||
|
|||||||
@@ -29,11 +29,9 @@ import com.intellij.openapi.vfs.VfsUtil
|
|||||||
import com.intellij.openapi.vfs.VfsUtilCore
|
import com.intellij.openapi.vfs.VfsUtilCore
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.annotations.Contract
|
import org.jetbrains.annotations.Contract
|
||||||
import org.jetbrains.kotlin.config.ApiVersion
|
import org.jetbrains.kotlin.config.*
|
||||||
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||||
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion
|
import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion
|
||||||
import org.jetbrains.kotlin.idea.framework.ui.CreateLibraryDialogWithModules
|
import org.jetbrains.kotlin.idea.framework.ui.CreateLibraryDialogWithModules
|
||||||
import org.jetbrains.kotlin.idea.framework.ui.FileUIUtils
|
import org.jetbrains.kotlin.idea.framework.ui.FileUIUtils
|
||||||
@@ -112,6 +110,11 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj
|
|||||||
|
|
||||||
configureKotlinSettings(modulesToConfigure)
|
configureKotlinSettings(modulesToConfigure)
|
||||||
|
|
||||||
|
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
|
||||||
|
languageVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
|
||||||
|
apiVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
|
||||||
|
}
|
||||||
|
|
||||||
collector.showNotification()
|
collector.showNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
|
|
||||||
private fun restrictAPIVersions() {
|
private fun restrictAPIVersions() {
|
||||||
with(editor.compilerConfigurable) {
|
with(editor.compilerConfigurable) {
|
||||||
restrictAPIVersions(selectedLanguageVersion)
|
restrictAPIVersions(selectedLanguageVersionView.version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
@@ -31,6 +31,11 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor
|
|||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.openapi.vfs.VfsUtil
|
import com.intellij.openapi.vfs.VfsUtil
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
|
import org.jetbrains.kotlin.config.VersionView
|
||||||
|
import org.jetbrains.kotlin.config.apiVersionView
|
||||||
|
import org.jetbrains.kotlin.config.languageVersionView
|
||||||
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator
|
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.FileState.COPY
|
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.FileState.COPY
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.FileState.DO_NOT_COPY
|
import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.FileState.DO_NOT_COPY
|
||||||
@@ -96,6 +101,11 @@ abstract class CustomLibraryDescriptorWithDeferredConfig
|
|||||||
|
|
||||||
configureKotlinSettings(module.project, rootModel.sdk)
|
configureKotlinSettings(module.project, rootModel.sdk)
|
||||||
|
|
||||||
|
KotlinCommonCompilerArgumentsHolder.getInstance(module.project).update {
|
||||||
|
languageVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
|
||||||
|
apiVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
|
||||||
|
}
|
||||||
|
|
||||||
collector.showNotification()
|
collector.showNotification()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="KotlinCommonCompilerArguments">
|
||||||
|
<option name="apiVersion" value="1.2" />
|
||||||
|
<option name="languageVersion" value="1.2" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
Vendored
Generated
Vendored
BIN
Binary file not shown.
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<resourceExtensions />
|
||||||
|
<wildcardResourcePatterns>
|
||||||
|
<entry name="!?*.java" />
|
||||||
|
<entry name="!?*.form" />
|
||||||
|
<entry name="!?*.class" />
|
||||||
|
<entry name="!?*.groovy" />
|
||||||
|
<entry name="!?*.scala" />
|
||||||
|
<entry name="!?*.flex" />
|
||||||
|
<entry name="!?*.kt" />
|
||||||
|
<entry name="!?*.clj" />
|
||||||
|
<entry name="!?*.aj" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="" />
|
||||||
|
</component>
|
||||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="KotlinJavaRuntime">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/kotlin-runtime.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
BIN
Binary file not shown.
+11
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<resourceExtensions />
|
||||||
|
<wildcardResourcePatterns>
|
||||||
|
<entry name="!?*.java" />
|
||||||
|
<entry name="!?*.form" />
|
||||||
|
<entry name="!?*.class" />
|
||||||
|
<entry name="!?*.groovy" />
|
||||||
|
<entry name="!?*.scala" />
|
||||||
|
<entry name="!?*.flex" />
|
||||||
|
<entry name="!?*.kt" />
|
||||||
|
<entry name="!?*.clj" />
|
||||||
|
<entry name="!?*.aj" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
idea/testData/configuration/noKotlincExistsNoSettingsRuntime10/.idea/copyright/profiles_settings.xml
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="" />
|
||||||
|
</component>
|
||||||
idea/testData/configuration/noKotlincExistsNoSettingsRuntime10/.idea/libraries/KotlinJavaRuntime.xml
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="KotlinJavaRuntime">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/kotlin-runtime.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
@@ -48,16 +48,16 @@ class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun testKotlincExistsNoSettingsRuntime10() {
|
fun testNoKotlincExistsNoSettingsRuntime10() {
|
||||||
val application = ApplicationManager.getApplication() as ApplicationImpl
|
val application = ApplicationManager.getApplication() as ApplicationImpl
|
||||||
application.doNotSave(false)
|
application.doNotSave(false)
|
||||||
Assert.assertEquals(LanguageVersion.KOTLIN_1_0, module.languageVersionSettings.languageVersion)
|
Assert.assertEquals(LanguageVersion.KOTLIN_1_0, module.languageVersionSettings.languageVersion)
|
||||||
Assert.assertEquals(LanguageVersion.KOTLIN_1_0, myProject.getLanguageVersionSettings(null).languageVersion)
|
Assert.assertEquals(LanguageVersion.KOTLIN_1_0, myProject.getLanguageVersionSettings(null).languageVersion)
|
||||||
application.saveAll()
|
application.saveAll()
|
||||||
Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") != null)
|
Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") == null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testKotlincExistsNoSettingsLatestRuntime() {
|
fun testNoKotlincExistsNoSettingsLatestRuntime() {
|
||||||
val application = ApplicationManager.getApplication() as ApplicationImpl
|
val application = ApplicationManager.getApplication() as ApplicationImpl
|
||||||
application.doNotSave(false)
|
application.doNotSave(false)
|
||||||
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
|
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
|
||||||
@@ -66,6 +66,31 @@ class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinTest() {
|
|||||||
Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") == null)
|
Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") == null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testKotlincExistsNoSettingsLatestRuntimeNoVersionAutoAdvance() {
|
||||||
|
val application = ApplicationManager.getApplication() as ApplicationImpl
|
||||||
|
application.doNotSave(false)
|
||||||
|
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
|
||||||
|
Assert.assertEquals(LanguageVersion.LATEST_STABLE, myProject.getLanguageVersionSettings(null).languageVersion)
|
||||||
|
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
|
||||||
|
autoAdvanceLanguageVersion = false
|
||||||
|
autoAdvanceApiVersion = false
|
||||||
|
}
|
||||||
|
application.saveAll()
|
||||||
|
Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") != null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDropKotlincOnVersionAutoAdvance() {
|
||||||
|
val application = ApplicationManager.getApplication() as ApplicationImpl
|
||||||
|
application.doNotSave(false)
|
||||||
|
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
|
||||||
|
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
|
||||||
|
autoAdvanceLanguageVersion = true
|
||||||
|
autoAdvanceApiVersion = true
|
||||||
|
}
|
||||||
|
application.saveAll()
|
||||||
|
Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") == null)
|
||||||
|
}
|
||||||
|
|
||||||
fun testProject106InconsistentVersionInConfig() {
|
fun testProject106InconsistentVersionInConfig() {
|
||||||
val settings = KotlinFacetSettingsProvider.getInstance(myProject).getInitializedSettings(module)
|
val settings = KotlinFacetSettingsProvider.getInstance(myProject).getInitializedSettings(module)
|
||||||
Assert.assertEquals(false, settings.useProjectSettings)
|
Assert.assertEquals(false, settings.useProjectSettings)
|
||||||
|
|||||||
Reference in New Issue
Block a user