Java Code Examples for com.intellij.openapi.util.io.FileUtil#findAncestor()

The following examples show how to use com.intellij.openapi.util.io.FileUtil#findAncestor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeCoverageSuite.java    From intellij with Apache License 2.0 6 votes vote down vote up
/**
 * The deepest directory below which this suite's coverage data lies, or null if there is no
 * coverage data.
 */
@Nullable
File getDeepestRootDirectory() {
  ProjectData data = getCoverageData();
  if (data == null) {
    return null;
  }
  @SuppressWarnings("unchecked")
  Set<String> files = data.getClasses().keySet();
  File root = null;
  for (String path : files) {
    if (root == null) {
      root = new File(path).getParentFile();
    } else {
      root = FileUtil.findAncestor(root, new File(path));
    }
  }
  return root;
}
 
Example 2
Source File: ChangesUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Find common ancestor for changes (included both before and after files)
 */
@javax.annotation.Nullable
public static File findCommonAncestor(@Nonnull Collection<Change> changes) {
  File ancestor = null;
  for (Change change : changes) {
    File currentChangeAncestor = getCommonBeforeAfterAncestor(change);
    if (currentChangeAncestor == null) return null;
    if (ancestor == null) {
      ancestor = currentChangeAncestor;
    }
    else {
      ancestor = FileUtil.findAncestor(ancestor, currentChangeAncestor);
      if (ancestor == null) return null;
    }
  }
  return ancestor;
}
 
Example 3
Source File: ChangesUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private static File getCommonBeforeAfterAncestor(@Nonnull Change change) {
  FilePath before = getBeforePath(change);
  FilePath after = getAfterPath(change);
  return before == null
         ? ObjectUtils.assertNotNull(after).getIOFile()
         : after == null ? before.getIOFile() : FileUtil.findAncestor(before.getIOFile(), after.getIOFile());
}