@Override @SuppressWarnings("HardCodedStringLiteral") public void setupSdkPaths(@NotNull Sdk sdk) { String homePath = sdk.getHomePath(); assert homePath != null : sdk; File jdkHome = new File(homePath); List<VirtualFile> classes = findClasses(jdkHome, false); VirtualFile sources = findSources(jdkHome); VirtualFile docs = findDocs(jdkHome, "docs/api"); SdkModificator sdkModificator = sdk.getSdkModificator(); Set<VirtualFile> previousRoots = new LinkedHashSet<>(Arrays.asList(sdkModificator.getRoots(OrderRootType.CLASSES))); sdkModificator.removeRoots(OrderRootType.CLASSES); previousRoots.removeAll(new HashSet<>(classes)); for (VirtualFile aClass : classes) { sdkModificator.addRoot(aClass, OrderRootType.CLASSES); } for (VirtualFile root : previousRoots) { sdkModificator.addRoot(root, OrderRootType.CLASSES); } if (sources != null) { sdkModificator.addRoot(sources, OrderRootType.SOURCES); } VirtualFile javaFxSources = findSources(jdkHome, "javafx-src"); if (javaFxSources != null) { sdkModificator.addRoot(javaFxSources, OrderRootType.SOURCES); } if (docs != null) { sdkModificator.addRoot(docs, JavadocOrderRootType.getInstance()); } else if (SystemInfo.isMac) { VirtualFile commonDocs = findDocs(jdkHome, "docs"); if (commonDocs == null) { commonDocs = findInJar(new File(jdkHome, "docs.jar"), "doc/api"); if (commonDocs == null) { commonDocs = findInJar(new File(jdkHome, "docs.jar"), "docs/api"); } } if (commonDocs != null) { sdkModificator.addRoot(commonDocs, JavadocOrderRootType.getInstance()); } VirtualFile appleDocs = findDocs(jdkHome, "appledocs"); if (appleDocs == null) { appleDocs = findInJar(new File(jdkHome, "appledocs.jar"), "appledoc/api"); } if (appleDocs != null) { sdkModificator.addRoot(appleDocs, JavadocOrderRootType.getInstance()); } if (commonDocs == null && appleDocs == null && sources == null) { String url = getDefaultDocumentationUrl(sdk); if (url != null) { sdkModificator.addRoot( VirtualFileManager.getInstance().findFileByUrl(url), JavadocOrderRootType.getInstance()); } } } else if (getVersion(sdk) == JavaSdkVersion.JDK_1_7) { VirtualFile url = VirtualFileManager.getInstance().findFileByUrl("http://docs.oracle.com/javafx/2/api/"); sdkModificator.addRoot(url, JavadocOrderRootType.getInstance()); } attachJdkAnnotations(sdkModificator); sdkModificator.commitChanges(); }
public void addDeleted(Collection<String> paths) { if (!myNeedRescan) { myChanged.removeAll(paths); myDeleted.addAll(paths); } }