Package org.eclipse.emf.compare.merge
Class ComputeDiffsToMerge
java.lang.Object
org.eclipse.emf.compare.merge.ComputeDiffsToMerge
This class computes the diffs to merge for a given diff in the correct order, taking into account the
merger's indications about required and consequent diffs.
- Required diffs
- These are the diffs that need to be merged (from a structural point of view) before a given diff for this diff to be mergeable by the merger.
- Consequent diffs
- These are all the diffs that, for some reason, the merger considers necessary to merge along with a given diff, but which need not be merged before this diff for the merger to be able to merge it. This is used to define atomicity of merge operations: Each merger defines the set of diffs that must be merged together, and the engine makes surre all these diffs (required+consequent) are merged together or not at all in one 'transaction'.
- Since:
- 3.5
-
Constructor Summary
ConstructorDescriptionComputeDiffsToMerge
(boolean rightToLeft, IDiffRelationshipComputer relationshipComputer) Constructor if there is no merge mode for this action.ComputeDiffsToMerge
(MergeMode mergeMode, boolean isLeftEditable, boolean isRightEditable, IDiffRelationshipComputer relationshipComputer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Compute the ordered set of diffs for the given diff.protected void
Recursively add the required diffs, then the diff itself, to the result.protected void
addDiffs
(Collection<Diff> diffs, Set<Diff> diffPath) Recursively add the given diffs to the result Set, starting by their requirements, then themselves, then their consequences, in the right order.failOnRealConflictUnless
(com.google.common.base.Predicate<? super Conflict> predicate) Set the failOnConflict flag.getAllDiffsToMerge
(Iterable<? extends Diff> diffs) Compute the ordered set of diffs to merge for the given diffs.getAllDiffsToMerge
(Diff diff) Compute the ordered set of diffs to merge for the given diff.
-
Constructor Details
-
ComputeDiffsToMerge
public ComputeDiffsToMerge(MergeMode mergeMode, boolean isLeftEditable, boolean isRightEditable, IDiffRelationshipComputer relationshipComputer) Constructor.- Parameters:
mergeMode
- The kind of merging we're about to implement.isLeftEditable
- Whether the left side of the comparison we're operating on is editable.isRightEditable
- Whether the right side of the comparison we're operating on is editable.relationshipComputer
- The relationship computer used to calculate dependencies and requirements of diffs.
-
ComputeDiffsToMerge
Constructor if there is no merge mode for this action.- Parameters:
rightToLeft
- Direction of the merge.relationshipComputer
- The relationship computer used to calculate dependencies and requirements of diffs.
-
-
Method Details
-
failOnRealConflictUnless
public ComputeDiffsToMerge failOnRealConflictUnless(com.google.common.base.Predicate<? super Conflict> predicate) Set the failOnConflict flag.- Parameters:
predicate
- Predicate that will be used to check whether an exception must be thrown when encountering a diff that's involved in a conflict. This predicate will be applied to the conflict, and if it returnsfalse
then an exception will be thrown.- Returns:
- This for a fluent API.
-
getAllDiffsToMerge
Compute the ordered set of diffs to merge for the given diffs.- Parameters:
diffs
- The diffs to merge, along with its required diffs and its consequent diffs.- Returns:
- An ordered Set that contains all the diffs to merge, in the correct order based on required diffs and consequent diffs.
-
getAllDiffsToMerge
Compute the ordered set of diffs to merge for the given diff.- Parameters:
diff
- The diff to merge, along with its required diffs and its consequent diffs.- Returns:
- An ordered Set that contains all the diffs to merge, in the correct order.
-
addDiff
Compute the ordered set of diffs for the given diff.- Parameters:
diff
- The diff to merge
-
addDiffs
Recursively add the given diffs to the result Set, starting by their requirements, then themselves, then their consequences, in the right order.- Parameters:
diffs
- The diffs to merge at the current step of the computationdiffPath
- The path that lead to a diff
-
addDiff
Recursively add the required diffs, then the diff itself, to the result. Also add the consequent diffs of all the required diffs and the provided one to the given set of consequences.- Parameters:
diff
- The diff to addconsequences
- The set of diffs that must be merged at the next step.diffPath
- The path that lead to the diff to add
-