Merge remote-tracking branch 'origin/master' appcode/163.3052
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Mon, 22 Aug 2016 11:58:50 +0000 (13:58 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Mon, 22 Aug 2016 11:58:50 +0000 (13:58 +0200)
platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java

index e03d730962b12b48ff84c2cba61dbeb7fd68e808..6aaf553723caf894d30b2da0cababfb033e1ef86 100644 (file)
@@ -131,25 +131,10 @@ public class SdkConfigurationUtil {
                              final boolean silent,
                              @Nullable final SdkAdditionalData additionalData,
                              @Nullable final String customSdkSuggestedName) {
-    final List<Sdk> sdksList = Arrays.asList(allSdks);
-
     final ProjectJdkImpl sdk;
     try {
-      String sdkPath = sdkType.sdkPath(homeDir);
-
-      final String sdkName = customSdkSuggestedName == null
-                             ? createUniqueSdkName(sdkType, sdkPath, sdksList)
-                             : createUniqueSdkName(customSdkSuggestedName, sdksList);
-      sdk = new ProjectJdkImpl(sdkName, sdkType);
-
-      if (additionalData != null) {
-        // additional initialization.
-        // E.g. some ruby sdks must be initialized before
-        // setupSdkPaths() method invocation
-        sdk.setSdkAdditionalData(additionalData);
-      }
+      sdk = createSdk(allSdks, homeDir, sdkType, additionalData, customSdkSuggestedName);
 
-      sdk.setHomePath(sdkPath);
       sdkType.setupSdkPaths(sdk);
     }
     catch (Exception e) {
@@ -165,6 +150,32 @@ public class SdkConfigurationUtil {
     return sdk;
   }
 
+  @NotNull
+  public static ProjectJdkImpl createSdk(@NotNull Sdk[] allSdks,
+                                          @NotNull VirtualFile homeDir,
+                                          SdkType sdkType,
+                                          @Nullable SdkAdditionalData additionalData, @Nullable String customSdkSuggestedName) {
+    final List<Sdk> sdksList = Arrays.asList(allSdks);
+
+    String sdkPath = sdkType.sdkPath(homeDir);
+
+    final String sdkName = customSdkSuggestedName == null
+                           ? createUniqueSdkName(sdkType, sdkPath, sdksList)
+                           : createUniqueSdkName(customSdkSuggestedName, sdksList);
+
+    ProjectJdkImpl sdk = new ProjectJdkImpl(sdkName, sdkType);
+
+    if (additionalData != null) {
+      // additional initialization.
+      // E.g. some ruby sdks must be initialized before
+      // setupSdkPaths() method invocation
+      sdk.setSdkAdditionalData(additionalData);
+    }
+
+    sdk.setHomePath(sdkPath);
+    return sdk;
+  }
+
   public static void setDirectoryProjectSdk(@NotNull final Project project, @Nullable final Sdk sdk) {
     ApplicationManager.getApplication().runWriteAction(() -> {
       ProjectRootManager.getInstance(project).setProjectSdk(sdk);