Exemplo n.º 1
0
 @NotNull
 public Collection<VcsRef> refsToCommit(@NotNull Hash hash) {
   if (myRefsToHashes.containsKey(hash)) {
     return myRefsToHashes.get(hash);
   }
   return Collections.emptyList();
 }
 @Nullable
 private VirtualFile findLibraryRootInfo(@NotNull List<VirtualFile> hierarchy, boolean source) {
   Set<Library> librariesToIgnore = ContainerUtil.newHashSet();
   for (VirtualFile root : hierarchy) {
     librariesToIgnore.addAll(excludedFromLibraries.get(root));
     if (source
         && libraryOrSdkSources.contains(root)
         && (!sourceOfLibraries.containsKey(root)
             || !librariesToIgnore.containsAll(sourceOfLibraries.get(root)))) {
       return root;
     } else if (!source
         && libraryOrSdkClasses.contains(root)
         && (!classOfLibraries.containsKey(root)
             || !librariesToIgnore.containsAll(classOfLibraries.get(root)))) {
       return root;
     }
   }
   return null;
 }
 public void minus(Pair<String, AbstractVcs> pair) {
   final VirtualFile root = getRootForPath(pair.getFirst());
   if (root == null) return;
   synchronized (myLock) {
     final VcsRoot key = new VcsRoot(pair.getSecond(), root);
     if (myQueries.containsKey(key)) {
       myQueries.remove(key, pair.getFirst());
     }
     myChanged.remove(pair.getFirst());
   }
 }
  void commandFinished(final Project project) {
    checkOverwrites(project);
    if (myAddedFiles.containsKey(project)) {
      processAddedFiles(project);
    }
    processMovedFiles(project);
    if (myDeletedFiles.containsKey(project)) {
      processDeletedFiles(project);
    }

    final List<VcsException> exceptionList = myMoveExceptions.get(project);
    if (exceptionList != null && !exceptionList.isEmpty()) {
      AbstractVcsHelper.getInstance(project)
          .showErrors(exceptionList, SvnBundle.message("move.files.errors.title"));
    }

    if (!myFilesToRefresh.isEmpty()) {
      refreshFiles(project);
    }
  }
 @NotNull
 private LinkedHashSet<OrderEntry> getLibraryOrderEntries(
     @NotNull List<VirtualFile> hierarchy,
     @Nullable VirtualFile libraryClassRoot,
     @Nullable VirtualFile librarySourceRoot,
     @NotNull MultiMap<VirtualFile, OrderEntry> libClassRootEntries,
     @NotNull MultiMap<VirtualFile, OrderEntry> libSourceRootEntries) {
   LinkedHashSet<OrderEntry> orderEntries = ContainerUtil.newLinkedHashSet();
   for (VirtualFile root : hierarchy) {
     if (root.equals(libraryClassRoot) && !sourceRootOf.containsKey(root)) {
       orderEntries.addAll(libClassRootEntries.get(root));
     }
     if (root.equals(librarySourceRoot) && libraryClassRoot == null) {
       orderEntries.addAll(libSourceRootEntries.get(root));
     }
     if (libClassRootEntries.containsKey(root)
         || sourceRootOf.containsKey(root) && librarySourceRoot == null) {
       break;
     }
   }
   return orderEntries;
 }
 @Nullable
 private ModuleSourceOrderEntry getModuleSourceEntry(
     @NotNull List<VirtualFile> hierarchy,
     @NotNull VirtualFile moduleContentRoot,
     @NotNull MultiMap<VirtualFile, OrderEntry> libClassRootEntries) {
   Module module = contentRootOf.get(moduleContentRoot);
   for (VirtualFile root : hierarchy) {
     if (sourceRootOf.get(root).contains(module)) {
       return ContainerUtil.findInstance(
           ModuleRootManager.getInstance(module).getOrderEntries(),
           ModuleSourceOrderEntry.class);
     }
     if (libClassRootEntries.containsKey(root)) {
       return null;
     }
   }
   return null;
 }
 @Nullable
 private VirtualFile findPackageRootInfo(
     @NotNull List<VirtualFile> hierarchy,
     VirtualFile moduleContentRoot,
     VirtualFile libraryClassRoot,
     VirtualFile librarySourceRoot) {
   for (VirtualFile root : hierarchy) {
     if (moduleContentRoot != null
         && sourceRootOf.get(root).contains(contentRootOf.get(moduleContentRoot))
         && librarySourceRoot == null) {
       return root;
     }
     if (root.equals(libraryClassRoot) || root.equals(librarySourceRoot)) {
       return root;
     }
     if (root.equals(moduleContentRoot)
         && !sourceRootOf.containsKey(root)
         && librarySourceRoot == null
         && libraryClassRoot == null) {
       return null;
     }
   }
   return null;
 }
Exemplo n.º 8
0
  /**
   * Arranges (re-orders) given entries according to the given rules.
   *
   * @param entries entries to arrange
   * @param rules rules to use for arrangement
   * @param rulesByPriority rules sorted by priority ('public static' rule will have higher priority
   *     than 'public')
   * @param <E> arrangement entry type
   * @return arranged list of the given rules
   */
  @SuppressWarnings("AssignmentToForLoopParameter")
  @NotNull
  public static <E extends ArrangementEntry> List<E> arrange(
      @NotNull Collection<E> entries,
      @NotNull List<? extends ArrangementMatchRule> rules,
      @NotNull List<? extends ArrangementMatchRule> rulesByPriority) {
    List<E> arranged = ContainerUtilRt.newArrayList();
    Set<E> unprocessed = ContainerUtilRt.newLinkedHashSet();
    List<Pair<Set<ArrangementEntry>, E>> dependent = ContainerUtilRt.newArrayList();
    for (E entry : entries) {
      List<? extends ArrangementEntry> dependencies = entry.getDependencies();
      if (dependencies == null) {
        unprocessed.add(entry);
      } else {
        if (dependencies.size() == 1 && dependencies.get(0) == entry.getParent()) {
          // Handle a situation when the entry is configured to be at the first parent's children.
          arranged.add(entry);
        } else {
          Set<ArrangementEntry> first = new HashSet<ArrangementEntry>(dependencies);
          dependent.add(Pair.create(first, entry));
        }
      }
    }

    Set<E> matched = new HashSet<E>();

    MultiMap<ArrangementMatchRule, E> elementsByRule = new MultiMap<ArrangementMatchRule, E>();
    for (ArrangementMatchRule rule : rulesByPriority) {
      matched.clear();
      for (E entry : unprocessed) {
        if (entry.canBeMatched() && rule.getMatcher().isMatched(entry)) {
          elementsByRule.putValue(rule, entry);
          matched.add(entry);
        }
      }
      unprocessed.removeAll(matched);
    }

    for (ArrangementMatchRule rule : rules) {
      if (elementsByRule.containsKey(rule)) {
        final Collection<E> arrangedEntries = elementsByRule.get(rule);

        // Sort by name if necessary.
        if (StdArrangementTokens.Order.BY_NAME.equals(rule.getOrderType())) {
          sortByName((List<E>) arrangedEntries);
        }
        arranged.addAll(arrangedEntries);
      }
    }
    arranged.addAll(unprocessed);

    for (int i = 0; i < arranged.size() && !dependent.isEmpty(); i++) {
      E e = arranged.get(i);
      for (Iterator<Pair<Set<ArrangementEntry>, E>> iterator = dependent.iterator();
          iterator.hasNext(); ) {
        Pair<Set<ArrangementEntry>, E> pair = iterator.next();
        pair.first.remove(e);
        if (pair.first.isEmpty()) {
          iterator.remove();
          arranged.add(i + 1, pair.second);
        }
      }
    }

    return arranged;
  }