Cleanup (migrates deprecated SdkVersionUtil usages)

This commit is contained in:
Roman Shevchenko
2017-12-21 16:58:52 +01:00
parent cc63a5504b
commit 777e4da5dc
3 changed files with 15 additions and 60 deletions
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 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.execution.util;
@@ -26,17 +14,17 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.jps.model.java.JdkVersionDetector;
public class JreVersionDetector {
private String myLastAlternativeJrePath ; //awful hack
private boolean myLastIsJre50;
public boolean isModuleJre50Configured(final ModuleBasedConfiguration configuration) {
final Module module = configuration.getConfigurationModule().getModule();
if (module != null && !module.isDisposed()) {
return isJre50(ModuleRootManager.getInstance(module).getSdk());
}
return isJre50(ProjectRootManager.getInstance(configuration.getProject()).getProjectSdk());
Module module = configuration.getConfigurationModule().getModule();
Sdk sdk = module != null && !module.isDisposed() ? ModuleRootManager.getInstance(module).getSdk()
: ProjectRootManager.getInstance(configuration.getProject()).getProjectSdk();
return JavaSdkUtil.isJdkAtLeast(sdk, JavaSdkVersion.JDK_1_5);
}
public boolean isJre50Configured(final CommonJavaRunConfigurationParameters configuration) {
@@ -48,22 +36,12 @@ public class JreVersionDetector {
}
myLastAlternativeJrePath = alternativeJrePath;
String versionString = SdkVersionUtil.detectJdkVersion(myLastAlternativeJrePath);
myLastIsJre50 = versionString != null && isJre50(versionString);
JdkVersionDetector.JdkVersionInfo jdkInfo = SdkVersionUtil.getJdkVersionInfo(myLastAlternativeJrePath);
myLastIsJre50 = jdkInfo != null && jdkInfo.version.feature >= 5;
return myLastIsJre50;
}
}
return false;
}
private static boolean isJre50(Sdk jdk) {
return JavaSdkUtil.isJdkAtLeast(jdk, JavaSdkVersion.JDK_1_5);
}
private static boolean isJre50(String versionString) {
if (versionString == null) return false;
JavaSdkVersion version = JavaSdkVersion.fromVersionString(versionString);
return version != null && version.isAtLeast(JavaSdkVersion.JDK_1_5);
}
}