コード例 #1
0
 /** Adds new CLASSES entries found in sys.path. */
 private static boolean addNewSysPathEntries(
     @NotNull Sdk sdk, @NotNull SdkModificator modificator, @NotNull List<String> sysPath) {
   final List<VirtualFile> oldRoots =
       Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
   PythonSdkAdditionalData additionalData =
       sdk.getSdkAdditionalData() instanceof PythonSdkAdditionalData
           ? (PythonSdkAdditionalData) sdk.getSdkAdditionalData()
           : null;
   List<String> newRoots = new ArrayList<String>();
   for (String root : sysPath) {
     if (new File(root).exists()
         && !FileUtilRt.extensionEquals(root, "egg-info")
         && (additionalData == null || !wasOldRoot(root, additionalData.getExcludedPathFiles()))
         && !wasOldRoot(root, oldRoots)) {
       newRoots.add(root);
     }
   }
   if (!newRoots.isEmpty()) {
     for (String root : newRoots) {
       PythonSdkType.addSdkRoot(modificator, root);
     }
     return true;
   }
   return false;
 }
コード例 #2
0
 private RootProvider getRootProvider() {
   if (myJdk != null) {
     return myJdk.getRootProvider();
   } else {
     return null;
   }
 }
コード例 #3
0
 private static void fillSdks(List<GlobalLibrary> globals) {
   for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
     final String name = sdk.getName();
     final String homePath = sdk.getHomePath();
     if (homePath == null) {
       continue;
     }
     final SdkAdditionalData data = sdk.getSdkAdditionalData();
     final String additionalDataXml;
     final SdkType sdkType = (SdkType) sdk.getSdkType();
     if (data == null) {
       additionalDataXml = null;
     } else {
       final Element element = new Element("additional");
       sdkType.saveAdditionalData(data, element);
       additionalDataXml = JDOMUtil.writeElement(element, "\n");
     }
     final List<String> paths =
         convertToLocalPaths(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
     String versionString = sdk.getVersionString();
     if (versionString != null && sdkType instanceof JavaSdk) {
       final JavaSdkVersion version = ((JavaSdk) sdkType).getVersion(versionString);
       if (version != null) {
         versionString = version.getDescription();
       }
     }
     globals.add(
         new SdkLibrary(
             name, sdkType.getName(), versionString, homePath, paths, additionalDataXml));
   }
 }
コード例 #4
0
 /** Removes legacy SOURCES entries in Python SDK tables (PY-2891). */
 private static boolean removeSourceRoots(@NotNull Sdk sdk, @NotNull SdkModificator modificator) {
   final VirtualFile[] sourceRoots = sdk.getRootProvider().getFiles(OrderRootType.SOURCES);
   if (sourceRoots.length > 0) {
     modificator.removeRoots(OrderRootType.SOURCES);
     return true;
   }
   return false;
 }
コード例 #5
0
 private static boolean isSdkOtpApp(@NotNull String otpAppName, @NotNull Sdk sdk) {
   Pattern appDirNamePattern = Pattern.compile(otpAppName + "-.*");
   for (VirtualFile srcSdkDir : sdk.getRootProvider().getFiles(OrderRootType.SOURCES)) {
     for (VirtualFile child : srcSdkDir.getChildren()) {
       if (child.isDirectory() && appDirNamePattern.matcher(child.getName()).find()) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #6
0
 /** Removes duplicate roots that have been added as the result of a bug with *.egg handling. */
 private static boolean removeDuplicateClassRoots(
     @NotNull Sdk sdk, @NotNull SdkModificator modificator) {
   final List<VirtualFile> sourceRoots =
       Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
   final LinkedHashSet<VirtualFile> uniqueRoots = new LinkedHashSet<VirtualFile>(sourceRoots);
   if (uniqueRoots.size() != sourceRoots.size()) {
     modificator.removeRoots(OrderRootType.CLASSES);
     for (VirtualFile root : uniqueRoots) {
       modificator.addRoot(root, OrderRootType.CLASSES);
     }
     return true;
   }
   return false;
 }
コード例 #7
0
 public RootProvider getRootProvider() {
   return myDelegate.getRootProvider();
 }