/**
  * Gets the array of common ancestors for passed files.
  *
  * @param files array of files
  * @return array of common ancestors for passed files
  */
 @NotNull
 public static VirtualFile[] getCommonAncestors(@NotNull VirtualFile[] files) {
   // Separate files by first component in the path.
   HashMap<VirtualFile, Set<VirtualFile>> map = new HashMap<VirtualFile, Set<VirtualFile>>();
   for (VirtualFile aFile : files) {
     VirtualFile directory = aFile.isDirectory() ? aFile : aFile.getParent();
     if (directory == null) return VirtualFile.EMPTY_ARRAY;
     VirtualFile[] path = getPathComponents(directory);
     Set<VirtualFile> filesSet;
     final VirtualFile firstPart = path[0];
     if (map.containsKey(firstPart)) {
       filesSet = map.get(firstPart);
     } else {
       filesSet = new THashSet<VirtualFile>();
       map.put(firstPart, filesSet);
     }
     filesSet.add(directory);
   }
   // Find common ancestor for each set of files.
   ArrayList<VirtualFile> ancestorsList = new ArrayList<VirtualFile>();
   for (Set<VirtualFile> filesSet : map.values()) {
     VirtualFile ancestor = null;
     for (VirtualFile file : filesSet) {
       if (ancestor == null) {
         ancestor = file;
         continue;
       }
       ancestor = getCommonAncestor(ancestor, file);
       // assertTrue(ancestor != null);
     }
     ancestorsList.add(ancestor);
     filesSet.clear();
   }
   return toVirtualFileArray(ancestorsList);
 }
 @TestOnly
 public void clearUncommittedDocuments() {
   myLastCommittedTexts.clear();
   myUncommittedDocuments.clear();
   mySynchronizer.cleanupForNextTest();
 }