restore java version detection for android & plugins sdks (IDEA-187506)

This commit is contained in:
Anna.Kozlova
2018-03-09 16:38:06 +01:00
parent 621c604bde
commit a00d19098c
2 changed files with 20 additions and 1 deletions
@@ -22,7 +22,17 @@ public class JavaSdkVersionUtil {
}
public static JavaSdkVersion getJavaSdkVersion(@Nullable Sdk sdk) {
return sdk != null && sdk.getSdkType() instanceof JavaSdk ? ((JavaSdk)sdk.getSdkType()).getVersion(sdk) : null;
if (sdk != null) {
SdkTypeId sdkType = sdk.getSdkType();
if (!(sdkType instanceof JavaSdk) && sdkType instanceof SdkType) {
sdkType = ((SdkType)sdkType).getDependencyType();
}
if (sdkType instanceof JavaSdk) {
return ((JavaSdk)sdkType).getVersion(sdk);
}
}
return null;
}
@Nullable
@@ -225,6 +225,15 @@ public abstract class SdkType implements SdkTypeId {
throw new IllegalArgumentException("Unknown SDk type: " + sdkTypeClass);
}
/**
* @return for sdk build over another sdk, returns type of the nested sdk,
* e.g. plugins or android sdks are build over java sdk and for them the method returns {@link JavaSdkType},
* null otherwise
*/
protected SdkType getDependencyType() {
return null;
}
public boolean isRootTypeApplicable(@NotNull OrderRootType type) {
return true;
}