diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkAuto.kt b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkAuto.kt index 1f9e4b73a7c8..73352f168db2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkAuto.kt +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkAuto.kt @@ -148,6 +148,8 @@ class JdkAuto : UnknownSdkResolver, JdkDownloaderBase { return object: UnknownSdkDownloadableSdkFix { override fun getVersionString() = jdkToDownload.versionString + override fun getPresentableVersionString() = jdkToDownload.presentableVersionString + override fun getDownloadDescription() = jdkToDownload.fullPresentationText override fun createTask(indicator: ProgressIndicator): SdkDownloadTask { @@ -217,6 +219,7 @@ class JdkAuto : UnknownSdkResolver, JdkDownloaderBase { val suggestedName: String) : UnknownSdkLocalSdkFix { override fun getExistingSdkHome() = homeDir override fun getVersionString() = JdkVersionDetector.formatVersionString(version) + override fun getPresentableVersionString() = version.toFeatureMinorUpdateString() override fun getSuggestedSdkName() : String = suggestedName } } diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkList.kt b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkList.kt index 02af3da72b89..09163b4736f8 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkList.kt +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/jdkDownloader/JdkList.kt @@ -119,6 +119,9 @@ data class JdkItem( val versionString get() = JavaVersion.tryParse(jdkVersion)?.let(JdkVersionDetector::formatVersionString) ?: jdkVersion + val presentableVersionString + get() = JavaVersion.tryParse(jdkVersion)?.toFeatureMinorUpdateString() ?: jdkVersion + val versionPresentationText: String get() = jdkVersion diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkDownloadableSdkFix.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkDownloadableSdkFix.java index 0197ee750b4d..e92aeda91085 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkDownloadableSdkFix.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkDownloadableSdkFix.java @@ -2,6 +2,7 @@ package com.intellij.openapi.roots.ui.configuration; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.ui.configuration.projectRoot.SdkDownloadTask; import org.jetbrains.annotations.NotNull; @@ -15,11 +16,22 @@ public interface UnknownSdkDownloadableSdkFix { String getDownloadDescription(); /** - * @return it is helpful for the UI to know the version of the SDK - * beforehand (e.g. while the SDK is downloading) + * @return the actual version string of the SDK, + * it is used for {@link com.intellij.openapi.projectRoots.SdkModificator#setVersionString(String)} + * and should be similar to what the respective {@link com.intellij.openapi.projectRoots.SdkType} + * configures in {@link com.intellij.openapi.projectRoots.SdkType#setupSdkPaths(Sdk)} + * @see #getPresentableVersionString() + */ + @NotNull String getVersionString(); + + /** + * @return version string that is short and enough to be shown in UI + * @see #getVersionString() */ @NotNull - String getVersionString(); + default String getPresentableVersionString() { + return getVersionString(); + } /** * Creates and SDK download task to apply the fix. diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkLocalSdkFix.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkLocalSdkFix.java index 8e845f1418d3..15a4126e0619 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkLocalSdkFix.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/UnknownSdkLocalSdkFix.java @@ -1,6 +1,7 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.roots.ui.configuration; +import com.intellij.openapi.projectRoots.Sdk; import org.jetbrains.annotations.NotNull; /** @@ -14,10 +15,23 @@ public interface UnknownSdkLocalSdkFix { String getExistingSdkHome(); /** - * @return the actual version string of the SDK + * @return the actual version string of the SDK, + * it is used for {@link com.intellij.openapi.projectRoots.SdkModificator#setVersionString(String)} + * and should be similar to what the respective {@link com.intellij.openapi.projectRoots.SdkType} + * configures in {@link com.intellij.openapi.projectRoots.SdkType#setupSdkPaths(Sdk)} + * @see #getPresentableVersionString() */ @NotNull String getVersionString(); + /** + * @return version string that is short and enough to be shown in UI + * @see #getVersionString() + */ + @NotNull + default String getPresentableVersionString() { + return getVersionString(); + } + /** * @return suggested name for an SDK to be created, still, the name could * be altered to avoid conflicts