@Nullable private static String importKnowledgeAboutOldDartSdkAndReturnGlobalLibName( final @NotNull Project project) { final String oldDartSdkPath = PropertiesComponent.getInstance().getValue("dart_sdk_path"); PropertiesComponent.getInstance().unsetValue("dart_sdk_path"); final DartSdk sdk = DartSdk.getGlobalDartSdk(); if (sdk != null) { return sdk.getGlobalLibName(); } else if (DartSdkUtil.isDartSdkHome(oldDartSdkPath)) { if (DartiumUtil.getDartiumBrowser() == null) { // configure even if getDartiumPathForSdk() returns null DartiumUtil.ensureDartiumBrowserConfigured( DartiumUtil.getDartiumPathForSdk(oldDartSdkPath)); } return ApplicationManager.getApplication() .runWriteAction( new Computable<String>() { public String compute() { return DartSdkGlobalLibUtil.createDartSdkGlobalLib(project, oldDartSdkPath); } }); } return null; }
@Nullable static DartSdk getSdkByLibrary(@NotNull final Library library) { final VirtualFile[] roots = library.getFiles(OrderRootType.CLASSES); if (roots.length == 1 && DartSdkLibraryPresentationProvider.isDartSdkLibRoot(roots[0])) { final String homePath = roots[0].getParent().getPath(); final String version = StringUtil.notNullize(DartSdkUtil.getSdkVersion(homePath), UNKNOWN_VERSION); return new DartSdk(homePath, version); } return null; }