Skip to content
Snippets Groups Projects
Commit bfd72aa0 authored by Sebastian Krings's avatar Sebastian Krings
Browse files

port code used to ignore certain attribute changes from old emf to new emf

parent 5f49ca04
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.diff.DefaultDiffEngine;
import org.eclipse.emf.compare.diff.IDiffEngine;
import org.eclipse.emf.compare.match.DefaultComparisonFactory;
import org.eclipse.emf.compare.match.DefaultEqualityHelperFactory;
import org.eclipse.emf.compare.match.IComparisonFactory;
......@@ -30,6 +32,7 @@ import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
import org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl;
import org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl;
import org.eclipse.emf.compare.merge.BatchMerger;
import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.merge.IMerger.Registry;
import org.eclipse.emf.compare.merge.IMerger.RegistryImpl;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
......@@ -42,7 +45,9 @@ import org.eventb.emf.core.AttributeType;
import org.eventb.emf.core.CoreFactory;
import org.eventb.emf.core.EventBElement;
import org.eventb.emf.core.EventBNamedCommentedComponentElement;
import org.eventb.texttools.merge.EventBEObjectMatcher;
import org.eventb.texttools.diffmerge.EventBDiffProcessor;
import org.eventb.texttools.diffmerge.EventBEObjectMatcher;
import org.eventb.texttools.diffmerge.EventBMerger;
import org.eventb.texttools.prettyprint.PrettyPrinter;
import de.be4.eventb.core.parser.BException;
......@@ -178,12 +183,16 @@ public class PersistenceHelper {
// };
IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(
matcher, comparisonFactory);
matchEngineFactory.setRanking(20);
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
matchEngineRegistry.add(matchEngineFactory);
IDiffEngine diffEngine = new DefaultDiffEngine(
new EventBDiffProcessor());
EMFCompare comparator = EMFCompare.builder()
.setMatchEngineFactoryRegistry(matchEngineRegistry).build();
.setMatchEngineFactoryRegistry(matchEngineRegistry)
.setDiffEngine(diffEngine).build();
IComparisonScope scope = new DefaultComparisonScope(oldVersion,
newVersion, null);
......
package org.eventb.texttools.diffmerge;
import org.eclipse.emf.compare.DifferenceKind;
import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.diff.DiffBuilder;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eventb.emf.core.CorePackage;
public class EventBDiffProcessor extends DiffBuilder {
@Override
public void referenceChange(Match match, EReference reference,
EObject value, DifferenceKind kind, DifferenceSource source) {
super.referenceChange(match, reference, value, kind, source);
}
@Override
public void attributeChange(Match match, EAttribute attribute,
Object value, DifferenceKind kind, DifferenceSource source) {
// before the EMF update this code was found in EventBAttributesCheck
boolean ignore = false;
EObject container = attribute.eContainer();
// remove default ignore transient and derived since some of these are
// our user visible attributes
// ignore = ignore || attribute.isTransient();
// ignore = ignore || attribute.isDerived();
// ignore contents of string 2 string map entries (e.g. in
// RodinInternalDetails)
// FIXME: make this more specific to RodinInternalDetails
ignore = ignore
|| (container instanceof ENamedElement && "StringToStringMapEntry"
.equals(((ENamedElement) container).getName()));
// ignore contents of Annotations
// FIXME: make this more specific to RodinInternalDetails
ignore = ignore
|| container.equals(CorePackage.eINSTANCE.getAnnotation());
// ignore reference (instead, the derived attribute 'name' will be
// shown)
ignore = ignore
|| attribute.equals(CorePackage.eINSTANCE
.getEventBElement_Reference());
// ignore attributes of Abstract Extension
ignore = ignore
|| container.equals(CorePackage.eINSTANCE
.getAbstractExtension());
if (!ignore) {
super.attributeChange(match, attribute, value, kind, source);
}
}
@Override
public void resourceAttachmentChange(Match match, String uri,
DifferenceKind kind, DifferenceSource source) {
super.resourceAttachmentChange(match, uri, kind, source);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment