示例#1
0
 private <K, C extends ModelChange> Tuples._2<Map<K, C>, Map<K, C>> arrangeChanges(
     _FunctionTypes._return_P1_E0<? extends K, ? super C> changeToKey, Class<C> changeClass) {
   return MultiTuple.<Map<K, C>, Map<K, C>>from(
       MergeConflictsBuilder.<K, C>arrangeChanges(myMineChangeSet, changeToKey, changeClass),
       MergeConflictsBuilder.<K, C>arrangeChanges(
           myRepositoryChangeSet, changeToKey, changeClass));
 }
示例#2
0
  private void collectGroupChangesWithOthersConflicts(
      Map<Tuples._2<SNodeId, String>, List<NodeGroupChange>> arrangedChanges,
      ChangeSet thisChangeSet,
      ChangeSet otherChangeSet) {
    Map<SNodeId, DeleteRootChange> deleteRootChanges =
        MergeConflictsBuilder.<SNodeId, DeleteRootChange>arrangeChanges(
            thisChangeSet,
            new _FunctionTypes._return_P1_E0<SNodeId, DeleteRootChange>() {
              public SNodeId invoke(DeleteRootChange drc) {
                return drc.getRootId();
              }
            },
            DeleteRootChange.class);
    for (ModelChange change : ListSequence.fromList(otherChangeSet.getModelChanges())) {
      if (MapSequence.fromMap(myConflictingChanges).containsKey(change)) {
        continue;
      }

      SNodeId nodeId = null;
      if (change instanceof NodeChange) {
        nodeId = ((NodeChange) change).getAffectedNodeId();
      } else if (change instanceof NodeGroupChange) {
        nodeId = ((NodeGroupChange) change).getParentNodeId();
      }
      if (nodeId == null) {
        continue;
      }
      SNode node = myBaseModel.getNode(nodeId);
      while (node != null) {
        if (SNodeOperations.getParent(node) == null) {
          DeleteRootChange conflicting =
              MapSequence.fromMap(deleteRootChanges).get(node.getNodeId());
          if (conflicting != null) {
            addPossibleConflict(change, conflicting);
          }
        } else {
          Tuples._2<SNodeId, String> nodeRole =
              MultiTuple.<SNodeId, String>from(
                  SNodeOperations.getParent(node).getNodeId(),
                  SNodeOperations.getContainingLinkRole(node));
          final int index = SNodeOperations.getIndexInParent(node);
          NodeGroupChange conflicting =
              ListSequence.fromList(MapSequence.fromMap(arrangedChanges).get(nodeRole))
                  .findFirst(
                      new IWhereFilter<NodeGroupChange>() {
                        public boolean accept(NodeGroupChange ch) {
                          return ch.getBegin() <= index && index < ch.getEnd();
                        }
                      });
          if (conflicting != null) {
            addPossibleConflict(change, conflicting);
            break;
          }
        }
        node = SNodeOperations.getParent(node);
      }
    }
  }