IDEA-173405 Show jdk build number in switcher

Provided additional info in jdk switcher
This commit is contained in:
Alexey Ushakov
2017-05-31 13:58:00 +03:00
parent 588d978362
commit da2d2eb5c5
2 changed files with 16 additions and 4 deletions
@@ -51,7 +51,7 @@ public class JdkBundleList {
Pair<Version, Integer> versionUpdate = bundleDescriptor.getVersionUpdate();
boolean updateVersionMap = versionUpdate != null;
if (!bundleList.isEmpty() && updateVersionMap) {
JdkBundle latestJdk = nameVersionMap.get(bundleDescriptor.getNameVersion());
JdkBundle latestJdk = nameVersionMap.get(bundleDescriptor.getNameVersion().replaceFirst("\\(.*\\)", ""));
if (latestJdk != null) {
Pair<Version, Integer> latestVersionUpdate = latestJdk.getVersionUpdate();
if (latestVersionUpdate != null) {
@@ -51,6 +51,9 @@ public class JdkBundle {
@NotNull
private static final Pattern ARCH_64_BIT_PATTERN = Pattern.compile(".*64-Bit.*", Pattern.MULTILINE);
@NotNull
private static final Pattern BUILD_STR_PATTERN = Pattern.compile(".*\\([^-]*-(.*)\\).*", Pattern.MULTILINE);
@NotNull public static final Bitness runtimeBitness = is64BitJVM(System.getProperty("java.vm.name")) ? Bitness.x64 : Bitness.x32;
private static boolean is64BitRuntime() { return runtimeBitness == Bitness.x64; }
@@ -152,11 +155,13 @@ public class JdkBundle {
}
public String getVisualRepresentation() {
StringBuilder representation = new StringBuilder(myBundleName);
StringBuilder representation = new StringBuilder();
if (myVersionUpdate != null) {
representation.append(myVersionUpdate.first).append(myVersionUpdate.second > 0 ? "_" + myVersionUpdate.second : "");
representation.append(myVersionUpdate.first).append(myVersionUpdate.second > 0 ? "_" + myVersionUpdate.second : "").append(" ");
}
representation.append(myBundleName);
if (myBoot || myBundled) {
representation.append(" [");
if (myBoot) representation.append(myBundled ? "boot, " : "boot");
@@ -206,7 +211,7 @@ public class JdkBundle {
@NotNull
String getNameVersion() {
return myBundleName + (myVersionUpdate != null ? myVersionUpdate.first.toString() : "");
return myBundleName.replaceFirst("\\(.*\\)", "") + (myVersionUpdate != null ? myVersionUpdate.first.toString() : "");
}
private static Pair<Pair<String, Boolean>, Pair<Version, Integer>> getJDKNameArchVersionAndUpdate(File jvm, String homeSubPath) {
@@ -245,6 +250,13 @@ public class JdkBundle {
String versionLine = outputLines.get(0);
versionAndUpdate = VersionUtil.parseNewVersionAndUpdate(versionLine, LINE_TO_VERSION_PATTERNS);
displayVersion = versionLine.replaceFirst("\".*\"", "");
displayVersion = displayVersion.replaceFirst("version", "");
if (outputLines.size() >= 2) {
Matcher matcher = BUILD_STR_PATTERN.matcher(outputLines.get(1));
if (matcher.find()) {
displayVersion += "(" + matcher.group(1) + ")";
}
}
if (outputLines.size() >= 3) {
is64Bit = is64BitJVM(outputLines.get(2));
}