Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-04-14 10:04:30 -0400
committerlgoubet2019-04-14 10:04:30 -0400
commitf70feb71f1db3f98de2200c4ea6adefbf622588b (patch)
treebd8e71bafcba33bb86b188763e2f39079628316c
parentbe5bb041244737fc24fdc7e81222600a960a91b8 (diff)
downloadorg.eclipse.emf.compare-f70feb71f1db3f98de2200c4ea6adefbf622588b.tar.gz
org.eclipse.emf.compare-f70feb71f1db3f98de2200c4ea6adefbf622588b.tar.xz
org.eclipse.emf.compare-f70feb71f1db3f98de2200c4ea6adefbf622588b.zip
Iterate over the differences instead of the matches
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java36
1 files changed, 4 insertions, 32 deletions
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java
index 38a9fefc9..c19042627 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java
@@ -10,14 +10,12 @@
*******************************************************************************/
package org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.match;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.match.MatchOfContainmentReferenceChangeAdapter;
import org.eclipse.emf.compare.utils.EMFComparePredicates;
-import org.eclipse.emf.ecore.EObject;
/**
* Process a comparison to detect {@link Match}es related to containment ReferenceChange. Add a
@@ -42,37 +40,11 @@ public class MatchOfContainmentReferenceChangeProcessor {
* The {@link Comparison} to check.
*/
public void execute(Comparison comp) {
- for (Match rootMatch : comp.getMatches()) {
- checkForMatchRelatedToContainmentReferenceChange(rootMatch);
- }
- }
-
- /**
- * Check if the given {@link Match} is related to a containment ReferenceChange. If it is add a
- * {@link MatchOfContainmentReferenceChangeAdapter} to this {@link Match}. Also check for all sub-matches
- * of the given {@link Match}.
- *
- * @param match
- * The {@link Match} to check
- */
- protected void checkForMatchRelatedToContainmentReferenceChange(Match match) {
- EObject parentMatch = match.eContainer();
- if (parentMatch instanceof Match) {
- EList<Diff> differences = ((Match)parentMatch).getDifferences();
- for (Diff parentMatchDiff : differences) {
- if (EMFComparePredicates.CONTAINMENT_REFERENCE_CHANGE.apply(parentMatchDiff)) {
- EObject value = ((ReferenceChange)parentMatchDiff).getValue();
- if (value != null && (value.equals(match.getLeft()) || value.equals(match.getRight())
- || value.equals(match.getOrigin()))) {
- match.eAdapters().add(new MatchOfContainmentReferenceChangeAdapter(
- (ReferenceChange)parentMatchDiff));
- break;
- }
- }
+ for (Diff diff : comp.getDifferences()) {
+ if (EMFComparePredicates.CONTAINMENT_REFERENCE_CHANGE.apply(diff)) {
+ Match match = comp.getMatch(((ReferenceChange)diff).getValue());
+ match.eAdapters().add(new MatchOfContainmentReferenceChangeAdapter((ReferenceChange)diff));
}
}
- for (Match subMatch : match.getSubmatches()) {
- checkForMatchRelatedToContainmentReferenceChange(subMatch);
- }
}
}

Back to the top