private boolean isAboveSourceOfCopyOrMove(final Project p, File ioFile) {
   for (MovedFileInfo file : myMovedFiles) {
     if (FileUtil.isAncestor(ioFile, file.mySrc, false)) return true;
   }
   for (AddedFileInfo info : myAddedFiles.get(p)) {
     if (info.myCopyFrom != null && FileUtil.isAncestor(ioFile, info.myCopyFrom, false))
       return true;
   }
   return false;
 }
Пример #2
0
  @Override
  protected void tearDown() throws Exception {
    try {
      Disposer.dispose(myTestRootDisposable);
      cleanupSwingDataStructures();
      cleanupDeleteOnExitHookList();
    } finally {
      if (shouldContainTempFiles()) {
        FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
        if (ourPathToKeep != null && FileUtil.isAncestor(myTempDir, ourPathToKeep, false)) {
          File[] files = new File(myTempDir).listFiles();
          if (files != null) {
            for (File file : files) {
              if (!FileUtil.pathsEqual(file.getPath(), ourPathToKeep)) {
                FileUtil.delete(file);
              }
            }
          }
        } else {
          FileUtil.delete(new File(myTempDir));
        }
      }
    }

    UIUtil.removeLeakingAppleListeners();
    super.tearDown();
  }
  private void checkProjectRoots() {
    LocalFileSystem fs = LocalFileSystem.getInstance();
    if (!(fs instanceof LocalFileSystemImpl)) return;
    FileWatcher watcher = ((LocalFileSystemImpl) fs).getFileWatcher();
    if (!watcher.isOperational()) return;
    Collection<String> manualWatchRoots = watcher.getManualWatchRoots();
    if (manualWatchRoots.isEmpty()) return;
    VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
    if (roots.length == 0) return;

    List<String> nonWatched = new SmartList<String>();
    for (VirtualFile root : roots) {
      if (!(root.getFileSystem() instanceof LocalFileSystem)) continue;
      String rootPath = root.getPath();
      for (String manualWatchRoot : manualWatchRoots) {
        if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
          nonWatched.add(rootPath);
        }
      }
    }

    if (!nonWatched.isEmpty()) {
      String message = ApplicationBundle.message("watcher.non.watchable.project");
      watcher.notifyOnFailure(message, null);
      LOG.info("unwatched roots: " + nonWatched);
      LOG.info("manual watches: " + manualWatchRoots);
    }
  }
  private void checkFsSanity() {
    try {
      String path = myProject.getProjectFilePath();
      if (path == null || FileUtil.isAncestor(PathManager.getConfigPath(), path, true)) {
        return;
      }

      boolean actual = FileUtil.isFileSystemCaseSensitive(path);
      LOG.info(path + " case-sensitivity: " + actual);
      if (actual != SystemInfo.isFileSystemCaseSensitive) {
        int prefix =
            SystemInfo.isFileSystemCaseSensitive ? 1 : 0; // IDE=true -> FS=false -> prefix='in'
        String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title");
        String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix);
        Notifications.Bus.notify(
            new Notification(
                Notifications.SYSTEM_MESSAGES_GROUP_ID,
                title,
                text,
                NotificationType.WARNING,
                NotificationListener.URL_OPENING_LISTENER),
            myProject);
      }
    } catch (FileNotFoundException e) {
      LOG.warn(e);
    }
  }
  public void removeCoverageSuite(final CoverageSuite suite) {
    final String fileName = suite.getCoverageDataFileName();

    boolean deleteTraces = suite.isTracingEnabled();
    if (!FileUtil.isAncestor(PathManager.getSystemPath(), fileName, false)) {
      String message = "Would you like to delete file \'" + fileName + "\' ";
      if (deleteTraces) {
        message +=
            "and traces directory \'"
                + FileUtil.getNameWithoutExtension(new File(fileName))
                + "\' ";
      }
      message += "on disk?";
      if (Messages.showYesNoDialog(
              myProject, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon())
          == Messages.YES) {
        deleteCachedCoverage(fileName, deleteTraces);
      }
    } else {
      deleteCachedCoverage(fileName, deleteTraces);
    }

    myCoverageSuites.remove(suite);
    if (myCurrentSuitesBundle != null && myCurrentSuitesBundle.contains(suite)) {
      CoverageSuite[] suites = myCurrentSuitesBundle.getSuites();
      suites = ArrayUtil.remove(suites, suite);
      chooseSuitesBundle(suites.length > 0 ? new CoverageSuitesBundle(suites) : null);
    }
  }
Пример #6
0
 public static void addMappingIfSubRoot(
     @NotNull Project project, @NotNull String newRepositoryPath, @NotNull String vcsName) {
   if (project.getBasePath() != null
       && FileUtil.isAncestor(project.getBasePath(), newRepositoryPath, true)) {
     ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
     manager.setDirectoryMappings(
         VcsUtil.addMapping(manager.getDirectoryMappings(), newRepositoryPath, vcsName));
   }
 }
 private boolean isUnderOldDir(Change change, FilePath path) {
   if (change.getBeforeRevision() != null) {
     final boolean isUnder =
         FileUtil.isAncestor(
             path.getIOFile(), change.getBeforeRevision().getFile().getIOFile(), true);
     if (isUnder) {
       return true;
     }
   }
   if (change.getAfterRevision() != null) {
     final boolean isUnder =
         FileUtil.isAncestor(
             path.getIOFile(), change.getAfterRevision().getFile().getIOFile(), true);
     if (isUnder) {
       return isUnder;
     }
   }
   return false;
 }
Пример #8
0
  private boolean hasSwitchedRoots() {
    File currentRoot = myMergeContext.getWcInfo().getRootInfo().getIoFile();

    return myMergeContext
        .getVcs()
        .getAllWcInfos()
        .stream()
        .filter(info -> NestedCopyType.switched.equals(info.getType()))
        .anyMatch(info -> FileUtil.isAncestor(currentRoot, info.getRootInfo().getIoFile(), true));
  }
Пример #9
0
  private void addIfNotUnderRoot(
      final List<BuildRootDescriptor> descriptors, final File file, final Collection<File> roots) {
    for (File root : roots) {
      if (FileUtil.isAncestor(root, file, false)) {
        return;
      }
    }

    descriptors.add(new FlexSourceRootDescriptor(this, file));
  }
  @Nullable
  protected String resolveProjectPath(@NotNull Module module) {
    final String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
    String projectPath = ExternalSystemApiUtil.getExternalProjectPath(module);

    if (rootProjectPath == null || projectPath == null) return null;
    if (!FileUtil.isAncestor(rootProjectPath, projectPath, false)) {
      projectPath = rootProjectPath;
    }
    return projectPath;
  }
Пример #11
0
 private boolean checkForSwitchedRoots() {
   final List<WCInfo> infoList = myVcs.getAllWcInfos();
   boolean switchedFound = false;
   for (WCInfo wcInfo : infoList) {
     if (FileUtil.isAncestor(new File(myWcInfo.getPath()), new File(wcInfo.getPath()), true)
         && NestedCopyType.switched.equals(wcInfo.getType())) {
       switchedFound = true;
       break;
     }
   }
   if (switchedFound) {
     return prompt("There are some switched paths in the working copy. Do you want to continue?");
   }
   return true;
 }
 public boolean isExcluded(@NotNull String importPath) {
   for (String excludedPath : myExcludedPackages) {
     if (FileUtil.isAncestor(excludedPath, importPath, false)) return true;
   }
   return false;
 }
 private boolean isUnderOrAboveProjectDir(@NotNull String mapping) {
   String projectDir = ObjectUtils.assertNotNull(myProject.getBasePath());
   return mapping.equals(VcsDirectoryMapping.PROJECT_CONSTANT)
       || FileUtil.isAncestor(projectDir, mapping, false)
       || FileUtil.isAncestor(mapping, projectDir, false);
 }