UnknownSdk - extend the API to allow presentable version in addition to sdk version

GitOrigin-RevId: 9ee8d515daf4b9e246e53bd1c0c52ee03451c7ef
This commit is contained in:
Eugene Petrenko
2020-04-22 17:49:10 +00:00
committed by intellij-monorepo-bot
parent d76a39afee
commit 2ca5ad7ab6
4 changed files with 36 additions and 4 deletions
@@ -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
}
}
@@ -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
@@ -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.
@@ -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