public class DefaultConflictDetector extends Object implements IConflictDetector
This default implementation of IConflictDetector
should detect most generic cases, but is not aimed
at detecting conflicts at "business" level. For example, adding two enum literals of the same value but
distinct IDs might be seen as a conflict... but that is not the "generic" case.
Constructor and Description |
---|
DefaultConflictDetector() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkConflict(Comparison comparison,
Diff diff,
Iterable<Diff> candidates)
This will be called once for each difference in the comparison model.
|
protected void |
checkContainmentConflict(Comparison comparison,
ReferenceChange diff,
Iterable<ReferenceChange> candidates)
This will be called once for each ReferenceChange on containment references in the comparison model.
|
protected void |
checkContainmentConflict(Comparison comparison,
ReferenceChange diff,
ReferenceChange candidate)
For each couple of diffs on the same value in which one is a containment reference change, we will call
this in order to check for possible conflicts.
|
protected void |
checkContainmentFeatureMapConflict(Comparison comparison,
FeatureMapChange diff,
FeatureMapChange candidate)
For each couple of diffs on the same value in which one is a containment feature map change, we will
call this in order to check for possible conflicts.
|
protected void |
checkContainmentFeatureMapConflict(Comparison comparison,
FeatureMapChange diff,
Iterable<FeatureMapChange> candidates)
This will be called once for each FeatureMapChange on containment values in the comparison model.
|
protected void |
checkFeatureAddConflict(Comparison comparison,
Diff diff,
Iterable<Diff> candidates)
This will be called from
checkConflict(Comparison, Diff, Iterable) in order to detect
conflicts on a Diff that is of type "ADD" and which is not a containment reference change. |
protected void |
checkFeatureChangeConflict(Comparison comparison,
Diff diff,
Iterable<Diff> candidates)
This will be called from
checkConflict(Comparison, Diff, Iterable) in order to detect
conflicts on a Diff that is of type "CHANGE". |
protected void |
checkFeatureDeleteConflict(Comparison comparison,
Diff diff,
Iterable<Diff> candidates)
This will be called from
checkConflict(Comparison, Diff, Iterable) in order to detect
conflicts on a Diff that is of type "DELETE" and which is not a containment reference change. |
protected void |
checkFeatureMoveConflict(Comparison comparison,
Diff diff,
Iterable<Diff> candidates)
This will be called from
checkConflict(Comparison, Diff, Iterable) in order to detect
conflicts on a Diff that is of type "CHANGE" or "MOVE". |
protected void |
checkResourceAttachmentConflict(Comparison comparison,
ResourceAttachmentChange diff,
Iterable<Diff> candidates)
This will be called once for each ResourceAttachmentChange in the comparison model.
|
protected void |
checkResourceAttachmentConflict(Comparison comparison,
ResourceAttachmentChange diff,
ReferenceChange candidate)
This will be called from
checkResourceAttachmentConflict(Comparison, ResourceAttachmentChange, Iterable) for each
ReferenceChange in the comparison model that is on the other side and that impacts the changed root. |
protected void |
conflictOn(Comparison comparison,
Diff diff1,
Diff diff2,
ConflictKind kind)
This will be called whenever we detect a new conflict in order to create (or update) the actual
association.
|
void |
detect(Comparison comparison,
Monitor monitor)
This is the entry point of the conflict detection process.
|
protected MatchResource |
getMatchResource(Comparison comparison,
Resource resource)
Returns the MatchResource corresponding to the given
resource . |
protected boolean |
isMergeableText(String left,
String right,
String origin)
Specifies whether the given three versions of a text
left , right , and origin
are mergeable with a line-based three-way merge. |
public void detect(Comparison comparison, Monitor monitor)
It is expected to complete the input comparison
by iterating over the
differences
it contain, filling in all conflicts it can detect
between those Diffs.
detect
in interface IConflictDetector
comparison
- The comparison this engine is expected to complete.monitor
- The monitor to report progress or to check for cancellationIConflictDetector.detect(org.eclipse.emf.compare.Comparison,
org.eclipse.emf.common.util.Monitor)
protected void checkConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates)
comparison
- The originating comparison of those diffs.diff
- Diff for which we are to try and determine conflicts.candidates
- An iterable over the Diffs that possible candidates for conflicts.protected void checkContainmentConflict(Comparison comparison, ReferenceChange diff, Iterable<ReferenceChange> candidates)
comparison
- The originating comparison of those diffs.diff
- The reference change for which we are to try and determine conflicts.candidates
- An iterable over the ReferenceChanges that are possible candidates for conflicts.protected void checkContainmentConflict(Comparison comparison, ReferenceChange diff, ReferenceChange candidate)
Once here, we know that diff
is a containment reference change, and we known that diff
and candidate
are both pointing to the same value. candidate
can be a containment
reference change, but that is not a given.
comparison
- The originating comparison of those diffs.diff
- Containment reference changes for which we need to check possible conflicts.candidate
- A reference change that point to the same value as diff
.protected void checkContainmentFeatureMapConflict(Comparison comparison, FeatureMapChange diff, Iterable<FeatureMapChange> candidates)
comparison
- The originating comparison of those diffs.diff
- The feature map change for which we are to try and determine conflicts.candidates
- An iterable over the FeatureMapChanges that are possible candidates for conflicts.protected void checkContainmentFeatureMapConflict(Comparison comparison, FeatureMapChange diff, FeatureMapChange candidate)
Once here, we know that diff
is a containment feature map change, and we known that
diff
and candidate
are both pointing to the same value. candidate
can be a
containment feature map change, but that is not a given.
comparison
- The originating comparison of those diffs.diff
- Containment feature map changes for which we need to check possible conflicts.candidate
- A feature map change that point to the same value as diff
.protected void checkFeatureChangeConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates)
checkConflict(Comparison, Diff, Iterable)
in order to detect
conflicts on a Diff that is of type "CHANGE".
Those can only conflict with other CHANGE Diffs on the same reference.
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite
to diff
.protected boolean isMergeableText(String left, String right, String origin)
left
, right
, and origin
are mergeable with a line-based three-way merge.left
- The left version.right
- The right version.origin
- The original version.true
if they are mergeable, false otherwise.protected void checkFeatureMoveConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates)
checkConflict(Comparison, Diff, Iterable)
in order to detect
conflicts on a Diff that is of type "CHANGE" or "MOVE".
Those can only conflict with other Diffs of the same type on the same reference.
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite
to diff
.protected void checkFeatureDeleteConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates)
checkConflict(Comparison, Diff, Iterable)
in order to detect
conflicts on a Diff that is of type "DELETE" and which is not a containment reference change.
The only potential conflict for such a diff is a "MOVE" of that same value on the opposite side.
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite
to diff
.protected void checkFeatureAddConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates)
checkConflict(Comparison, Diff, Iterable)
in order to detect
conflicts on a Diff that is of type "ADD" and which is not a containment reference change.
These will conflict with Diffs on the other side on the same reference in the same container, of type ADD an on the same value.
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite
to diff
.protected void checkResourceAttachmentConflict(Comparison comparison, ResourceAttachmentChange diff, Iterable<Diff> candidates)
comparison
- The originating comparison of those diffs.diff
- The "root" difference for which we are to try and determine conflicts.candidates
- An iterable over the Diffs that are possible candidates for conflicts.protected MatchResource getMatchResource(Comparison comparison, Resource resource)
resource
.comparison
- the comparison to search for a MatchResource.resource
- Resource for which we need a MatchResource.resource
.protected void checkResourceAttachmentConflict(Comparison comparison, ResourceAttachmentChange diff, ReferenceChange candidate)
checkResourceAttachmentConflict(Comparison, ResourceAttachmentChange, Iterable)
for each
ReferenceChange in the comparison model that is on the other side and that impacts the changed root.comparison
- The originating comparison of those diffs.diff
- Resource attachment change for which we need to check possible conflicts.candidate
- A reference change that point to the same value as diff
.protected void conflictOn(Comparison comparison, Diff diff1, Diff diff2, ConflictKind kind)
comparison
- The originating comparison of those diffs.diff1
- First of the two differences for which we detected a conflict.diff2
- Second of the two differences for which we detected a conflict.kind
- Kind of this conflict.
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.