Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • develop
  • master
  • 3.4.0
  • 3.4.1
  • 3.5.0
  • 3.5.1
  • 3.6.0
7 results

Target

Select target project
  • general/stups/camille
1 result
Select Git revision
  • develop
  • master
  • 3.4.0
  • 3.4.1
  • 3.5.0
  • 3.5.1
  • 3.6.0
7 results
Show changes
Commits on Source (17)
Showing
with 39 additions and 536 deletions
......@@ -2,13 +2,14 @@
<feature
id="org.eventb.texteditor.feature"
label="Camille Text Editor"
version="3.5.1.qualifier"
provider-name="Heinrich-Heine University Dusseldorf"
version="3.6.0.qualifier"
provider-name="HHU Düsseldorf STUPS Group"
plugin="org.eventb.texteditor.ui">
<description>
A text editor for the Rodin platform to edit Event-B models
--- Release History ---
3.6.0 - Improved performance when saving larger files. Disallowed compatibility with Event-B EMF 7.0.0 again, because of a bug that breaks ordering of elements in a context/machine.
3.5.1 - Fix "Empty label" error when adding a variant to a machine
3.5.0 - Compatibility with EventB-EMF 7.0.0 - fixes CamilleX dependency conflict. Fixed OOM error when top-level end keyword is missing.
3.4.1 - Internal updates to the build process - no visible changes.
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.eventb.texteditor</groupId>
<artifactId>org.eventb.texteditor.parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.6.0-SNAPSHOT</version>
<relativePath>../org.eventb.texteditor.parent/pom.xml</relativePath>
</parent>
......
......@@ -4,7 +4,7 @@
<groupId>org.eventb.texteditor</groupId>
<artifactId>org.eventb.texteditor.parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.6.0-SNAPSHOT</version>
<packaging>pom</packaging>
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/guava-14.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jsr305-1.3.9.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/bparser-2.4.40.jar"/>
<classpathentry exported="true" kind="lib" path="lib/eventbstruct-2.4.40.jar"/>
<classpathentry exported="true" kind="lib" path="lib/parserbase-2.4.40.jar"/>
<classpathentry exported="true" kind="lib" path="lib/prologlib-2.4.40.jar"/>
<classpathentry kind="output" path="bin"/>
<classpathentry exported="true" kind="lib" path="lib/eventbstruct-2.13.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/sablecc-runtime-3.7.0.jar"/>
</classpath>
......@@ -2,13 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Parsers for Camille
Bundle-SymbolicName: org.eventb.texteditor.parsers
Bundle-Version: 3.5.1.qualifier
Bundle-Version: 3.6.0.qualifier
Bundle-Activator: org.eventb.texteditor.parsers.Activator
Require-Bundle: org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .,
lib/eventbstruct-2.12.7.jar,
lib/sablecc-runtime-3.6.0.jar
lib/eventbstruct-2.13.0.jar,
lib/sablecc-runtime-3.7.0.jar
Export-Package: de.be4.eventb.core.parser,
de.be4.eventb.core.parser.analysis,
de.be4.eventb.core.parser.lexer,
......@@ -16,5 +16,5 @@ Export-Package: de.be4.eventb.core.parser,
de.be4.eventb.core.parser.parser,
de.hhu.stups.sablecc.patch,
org.eventb.texteditor.parsers
Bundle-Vendor: Heinrich-Heine University Dusseldorf
Bundle-Vendor: HHU Düsseldorf STUPS Group
Bundle-ActivationPolicy: lazy
......@@ -2,5 +2,5 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
lib/eventbstruct-2.12.7.jar,\
lib/sablecc-runtime-3.6.0.jar
lib/eventbstruct-2.13.0.jar,\
lib/sablecc-runtime-3.7.0.jar
......@@ -6,7 +6,7 @@
<relativePath>../org.eventb.texteditor.parent/pom.xml</relativePath>
<groupId>org.eventb.texteditor</groupId>
<artifactId>org.eventb.texteditor.parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.6.0-SNAPSHOT</version>
</parent>
<artifactId>org.eventb.texteditor.parsers</artifactId>
......@@ -16,7 +16,7 @@
<dependency>
<groupId>de.hhu.stups</groupId>
<artifactId>eventbstruct</artifactId>
<version>2.12.7</version>
<version>2.13.0</version>
</dependency>
</dependencies>
......
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/org.eventb.texteditor.feature_3.5.1.qualifier.jar" id="org.eventb.texteditor.feature" version="3.5.1.qualifier">
<feature id="org.eventb.texteditor.feature" version="0.0.0">
<category name="org.eventb.texteditor.feature.category"/>
</feature>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>org.eventb.texteditor</groupId>
<artifactId>org.eventb.texteditor.parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.6.0-SNAPSHOT</version>
<relativePath>../org.eventb.texteditor.parent/pom.xml</relativePath>
</parent>
......
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Camille Texteditor
Bundle-Name: Camille Text Editor
Bundle-SymbolicName: org.eventb.texteditor.ui;singleton:=true
Bundle-Version: 3.5.1.qualifier
Bundle-Version: 3.6.0.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eventb.texteditor.ui.TextEditorPluginImplementation
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.8.1,4.0.0)",
......@@ -16,17 +16,17 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.8.1,4.0.0)",
org.eclipse.ui.workbench.texteditor,
org.eventb.core;bundle-version="[3.1.0,4.0.0)",
org.eventb.core.ast;bundle-version="[3.1.0,4.0.0)",
org.eventb.emf.core;bundle-version="[5.0.0,7.0.0)",
org.eventb.emf.formulas;bundle-version="[1.5.0,3.0.0)",
org.eventb.emf.persistence;bundle-version="[3.6.0,5.0.0)";visibility:=reexport,
org.eventb.texteditor.parsers;bundle-version="[3.5.1,3.6.0)",
org.eventb.texttools;bundle-version="[3.5.1,3.6.0)";visibility:=reexport,
org.eventb.emf.core;bundle-version="[5.0.0,6.0.0)",
org.eventb.emf.formulas;bundle-version="[1.5.0,2.0.0)",
org.eventb.emf.persistence;bundle-version="[3.6.0,4.0.0)";visibility:=reexport,
org.eventb.texteditor.parsers;bundle-version="[3.6.0,3.7.0)",
org.eventb.texttools;bundle-version="[3.6.0,3.7.0)";visibility:=reexport,
org.eventb.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.rodinp.core;bundle-version="[1.7.0,2.0.0)",
org.rodinp.keyboard.core;bundle-version="[2.0.0,3.0.0)",
org.rodinp.keyboard.ui;bundle-version="[2.0.0,3.0.0)"
Bundle-ClassPath: .
Bundle-Vendor: Heinrich-Heine University Dusseldorf
Bundle-Vendor: HHU Düsseldorf STUPS Group
Export-Package: org.eventb.texteditor.ui,
org.eventb.texteditor.ui.build,
org.eventb.texteditor.ui.build.dom,
......
aboutText=A text editor for the Rodin platform to edit Event-B models.
featureImage=icons/camille32.gif
......@@ -2,6 +2,7 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.ini,\
plugin.xml,\
plugin.properties,\
templates.xml,\
......
......@@ -4,7 +4,7 @@
#
# $Id$
pluginName = Camille Texteditor
pluginName = Camille Text Editor
_UI_CoreEditor_menu = &Core Editor
_UI_MachineEditor_menu = &Machine Editor
......@@ -40,7 +40,7 @@ _UI_MachineModelWizard_description = Create a new Machine model
_UI_MachineEditorFilenameDefaultBase = Machine
_UI_MachineEditorFilenameExtensions = bum
_UI_MachineEditor_label = Camille Texteditor
_UI_MachineEditor_label = Camille Text Editor
_UI_Wizard_label = New
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.eventb.texteditor</groupId>
<artifactId>org.eventb.texteditor.parent</artifactId>
<version>3.5.1-SNAPSHOT</version>
<version>3.6.0-SNAPSHOT</version>
<relativePath>../org.eventb.texteditor.parent/pom.xml</relativePath>
</parent>
......
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Event-B EMF Texttools
Bundle-SymbolicName: org.eventb.texttools;singleton:=true
Bundle-Version: 3.5.1.qualifier
Bundle-Version: 3.6.0.qualifier
Bundle-Activator: org.eventb.texttools.TextToolsPlugin
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.8.1,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.10.0,4.0.0)",
......@@ -15,12 +15,12 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.8.1,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.6.0,4.0.0)",
org.eventb.core;bundle-version="[3.1.0,4.0.0)",
org.eventb.core.ast;bundle-version="[3.1.0,4.0.0)",
org.eventb.emf.core;bundle-version="[5.0.0,7.0.0)",
org.eventb.emf.formulas;bundle-version="[1.5.0,3.0.0)",
org.eventb.emf.persistence;bundle-version="[3.6.0,5.0.0)",
org.eventb.texteditor.parsers;bundle-version="[3.5.1,3.6.0)",
org.eventb.emf.core;bundle-version="[5.0.0,6.0.0)",
org.eventb.emf.formulas;bundle-version="[1.5.0,2.0.0)",
org.eventb.emf.persistence;bundle-version="[3.6.0,4.0.0)",
org.eventb.texteditor.parsers;bundle-version="[3.6.0,3.7.0)",
org.rodinp.core;bundle-version="[1.7.0,2.0.0)"
Bundle-Vendor: Heinrich-Heine University Dusseldorf
Bundle-Vendor: HHU Düsseldorf STUPS Group
Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
......
/**
* Copyright (c) 2010
* University of Southampton and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
*
*
* $Id$
*/
package org.eventb.texttools.diff;
import org.eclipse.emf.compare.diff.engine.check.AttributesCheck;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer;
import org.eventb.emf.core.CorePackage;
public class EventBAttributesCheck extends AttributesCheck {
public EventBAttributesCheck(CrossReferencer referencer) {
super(referencer);
}
/**
* Determines if we should ignore an attribute for diff detection.
* <p>
* We do not ignore transient nor derived attributes by default because often these are the user visible/editable attribute. We ignore the reference attribute since name is the
* changeable part. We also ignore the attributes of Annotations and their maps
* </p>
*
* FIXME: Make this extensible via an extension point so that extenders can decide what should be ignored.
*
* @param attribute
* Attribute to determine whether it should be ignored.
* @return <code>True</code> if attribute has to be ignored, <code>False</code> otherwise.
*/
@Override
protected boolean shouldBeIgnored(EAttribute attribute) {
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());
return ignore;
}
}
/**
* Copyright (c) 2010
* University of Southampton and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
*
*
* $Id$
*/
package org.eventb.texttools.diff;
import java.util.List;
import org.eclipse.emf.compare.diff.engine.GenericDiffEngine;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
import org.eclipse.emf.compare.match.metamodel.UnmatchElement;
public class EventBDiffEngine extends GenericDiffEngine {
/**
* Returns the Event-B implementation of a
* {@link org.eclipse.emf.compare.diff.engine.check.AbstractCheck}
* responsible for the verification of updates on attribute values.
*
* @return The Event-B implementation of a
* {@link org.eclipse.emf.compare.diff.engine.check.AbstractCheck}
* responsible for the verification of updates on attribute values.
* @since 1.0
*/
@Override
protected EventBAttributesCheck getAttributesChecker() {
return new EventBAttributesCheck(matchCrossReferencer);
}
/**
* Returns the Event-B implementation of a
* {@link org.eclipse.emf.compare.diff.engine.check.AbstractCheck}
* responsible for the verification of updates on reference values.
*
* @return The Event-B implementation of a
* {@link org.eclipse.emf.compare.diff.engine.check.AbstractCheck}
* responsible for the verification of updates on reference values.
* @since 1.0
*/
@Override
protected EventBReferencesCheck getReferencesChecker() {
return new EventBReferencesCheck(matchCrossReferencer);
}
/**
* This will process the {@link #unmatchedElements unmatched elements} list
* and create the appropriate {@link DiffElement}s.
* <p>
* This is called for two-way comparison.
* </p>
* <p>
* Filters any unmatched elements according to the references checker. Rodin
* internal detail Annotation and then defers to the generic diff engine.
* </p>
* <p>
* FIXME: Make this extensible via an extension point so that extenders can
* decide what should be ignored.
* </p>
*
* @param diffRoot
* {@link DiffGroup} under which to create the
* {@link DiffElement}s.
* @param unmatched
* The MatchModel's {@link UnmatchElement}s.
*/
@Override
protected void processUnmatchedElements(DiffGroup diffRoot,
List<UnmatchElement> unmatched) {
super.processUnmatchedElements(diffRoot, getReferencesChecker()
.filterUnmatchedElements(unmatched));
}
}
/**
* Copyright (c) 2010
* University of Southampton and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
*
*
* $Id$
*/
package org.eventb.texttools.diff;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.compare.FactoryException;
import org.eclipse.emf.compare.diff.engine.check.ReferencesCheck;
import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
import org.eclipse.emf.compare.match.metamodel.Match2Elements;
import org.eclipse.emf.compare.match.metamodel.UnmatchElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer;
import org.eventb.emf.core.CorePackage;
public class EventBReferencesCheck extends ReferencesCheck {
public EventBReferencesCheck(CrossReferencer referencer) {
super(referencer);
}
/**
* Determines if we should ignore a reference for diff detection.
* This method is intended to be used to filter matched changes.
* Containments are dealt with as new element additions so these are ignored.
* Everything else is deferred to shouldBeIgnoredAllowContainments().
*
* @param reference
* Reference to determine whether it should be ignored.
* @return <code>True</code> if reference has to be ignored, <code>False</code> otherwise.
*/
@Override
protected boolean shouldBeIgnored(EReference reference) {
return reference.isContainment() ? true : shouldBeIgnoredAllowContainment(reference);
}
/**
* Determines if we should ignore a reference for diff detection.
* This method is intended to be used to filter matched or unmatched changes.
* (unmatched elements are additions to Containments)
* are dealt with as new element additions so these are ignored.
* Everything else is deferred to shouldBeIgnoredAllowContainments().
*
* <p>
* Apart from containment which is dealt with elsewhere, we copy the default which is to ignore references marked either
* <ul>
* <li>Container</li>
* <li>Transient</li>
* <li>Derived</li>
* </ul>
* </p>
* <p>
* We also ignore the references, refines, sees and extends because any differences will be shown in the derived attributes 'names' lists. We also ignore the containment,
* annotations, because it is only used to hold transient tool information. We also ignore anything contained by EcorePackage.eINSTANCE.getEGenericType() or
* CorePackage.eINSTANCE.getAnnotation()
*
* </p>
*
* FIXME: Make this extensible via an extension point so that extenders can decide what should be ignored.
*
* @param reference
* Reference to determine whether it should be ignored.
* @return <code>True</code> if reference has to be ignored, <code>False</code> otherwise.
*/
protected boolean shouldBeIgnoredAllowContainment(EReference reference) {
boolean ignore = false;
ignore = ignore || reference.isDerived();
ignore = ignore || reference.isTransient();
ignore = ignore || reference.isContainer();
ignore = ignore || reference.eContainer().equals(EcorePackage.eINSTANCE.getEGenericType());
String name = reference.getName();
ignore = ignore || "refines".equals(name);
ignore = ignore || "sees".equals(name);
ignore = ignore || "extends".equals(name);
ignore = ignore || "annotations".equals(name);
ignore = ignore || "extensions".equals(name);
// ignore = ignore || "attributes".equals(name); //Cannot ignore generic attributes since camille timestamp is an attribute
ignore = ignore || reference.eContainer().equals(CorePackage.eINSTANCE.getAnnotation());
return ignore;
}
@Override
protected void checkReferenceOrderChange(DiffGroup root, EReference reference, EObject leftElement, EObject rightElement,
List<ReferenceChangeLeftTarget> addedReferences, List<ReferenceChangeRightTarget> removedReferences) throws FactoryException {
if (shouldBeIgnored(reference)) {
return;
}
super.checkReferenceOrderChange(root, reference, leftElement, rightElement, addedReferences, removedReferences);
}
@Override
protected void checkContainmentReferenceOrderChange(DiffGroup root, Match2Elements mapping, EReference reference) throws FactoryException {
if (shouldBeIgnoredAllowContainment(reference)) {
return;
}
super.checkContainmentReferenceOrderChange(root, mapping, reference);
}
/**
* The standard difference checkers take no account of shouldBeIgnored references for unmatched elements.
* This additional method can be used to filter out new elements (that will have no match) from the differences.
* It returns a new list of UnmatchElement without any elements that are contained in a reference that should Be Ignored (i.e.
* for which shouldBeIgnored(containingFeature) returns true.
*
* @param unmatched
* : List<UnmatchElement>
* @return List<UnmatchElement>
*/
public List<UnmatchElement> filterUnmatchedElements(List<UnmatchElement> unmatched) {
final List<UnmatchElement> filteredUnmatched = new ArrayList<UnmatchElement>(unmatched.size());
for (UnmatchElement element : unmatched) {
if (element.getElement().eContainmentFeature() == null || !shouldBeIgnoredAllowContainment(element.getElement().eContainmentFeature())) {
filteredUnmatched.add(element);
}
}
return filteredUnmatched;
}
/**
* The standard difference checkers take no account of shouldBeIgnored references for unmatched elements.
* This additional method can be used to filter out new elements (that will have no match) from the differences.
* It returns a new list of UnmatchElement without any elements that are contained in a reference that should Be Ignored (i.e.
* for which shouldBeIgnored(containingFeature) returns true.
*
* @param unmatched
* : Map<UnmatchElement, Boolean>
* @return Map<UnmatchElement, Boolean>
*/
public Map<UnmatchElement, Boolean> filterUnmatchedElements(Map<UnmatchElement, Boolean> unmatched) {
final Map<UnmatchElement, Boolean> filteredUnmatched = new HashMap<UnmatchElement, Boolean>(unmatched.size());
for (final Map.Entry<UnmatchElement, Boolean> element : unmatched.entrySet()) {
if (!shouldBeIgnoredAllowContainment(element.getKey().getElement().eContainmentFeature())) {
filteredUnmatched.put(element.getKey(), element.getValue());
}
}
return filteredUnmatched;
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package org.eventb.texttools.merge;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.compare.FactoryException;
import org.eclipse.emf.compare.match.MatchOptions;
import org.eclipse.emf.compare.match.engine.GenericMatchEngine;
import org.eclipse.emf.compare.match.engine.IMatchEngine;
import org.eclipse.emf.compare.match.engine.MatchSettings;
import org.eclipse.emf.compare.match.internal.statistic.NameSimilarity;
import org.eclipse.emf.ecore.EObject;
import org.eventb.emf.core.EventBNamed;
import org.eventb.emf.core.EventBNamedCommentedComponentElement;
import org.eventb.emf.core.EventBPredicate;
import org.eventb.emf.core.machine.Event;
import org.eventb.emf.core.machine.Variant;
/**
* A {@link IMatchEngine} which matches EventB emf models. The special structure
* of those models is taken into consideration to produce more exact match
* models.
*/
public class EventBMatchEngine extends GenericMatchEngine {
public static final String OPTION_DONT_COMPARE_COMPONENTS = "eventb.dont.compare.components";
private static final Map<String, Object> defaultOptions = new HashMap<String, Object>();
static {
defaultOptions.put(OPTION_DONT_COMPARE_COMPONENTS, false);
}
public EventBMatchEngine() {
// needed for Extension Point
}
public EventBMatchEngine(final Map<String, Object> options) {
this.options.putAll(options);
}
@Override
public boolean isSimilar(final EObject obj1, final EObject obj2)
throws FactoryException {
/*
* Test if we consider components as match by default
*/
final Boolean dontCompareComponents = getOption(OPTION_DONT_COMPARE_COMPONENTS);
if (dontCompareComponents && areSameComponentType(obj1, obj2)) {
return true;
}
/*
* Only one variant may exist in a model, so two variants are a match
*/
if (areVariants(obj1, obj2)) {
return true;
}
/*
* Our models are typed strictly, that means: different type => no match
*/
if (!areSameType(obj1, obj2)) {
return false;
}
/*
* Improve matching for events with same name
*/
if (obj1 instanceof Event) {
final double similarity = nameSimilarity(obj1, obj2);
if (similarity == 1) {
return true;
}
}
// otherwise use default comparison of GenericMatchEngine
return super.isSimilar(obj1, obj2);
}
@Override
protected double nameSimilarity(final EObject obj1, final EObject obj2) {
if (!areSameType(obj1, obj2)) {
return 0d;
}
return NameSimilarity
.nameSimilarityMetric(getName(obj1), getName(obj2));
}
@Override
protected double contentSimilarity(final EObject obj1, final EObject obj2)
throws FactoryException {
if (!areSameType(obj1, obj2)) {
return 0d;
}
double result = super.contentSimilarity(obj1, obj2);
if (obj1 instanceof EventBPredicate) {
// give predicate equality extra weight
result = (result + 2 * contentSimilarity((EventBPredicate) obj1,
(EventBPredicate) obj2)) / 3;
}
return result;
}
private double contentSimilarity(final EventBPredicate pred1,
final EventBPredicate pred2) {
return NameSimilarity.nameSimilarityMetric(pred1.getPredicate(),
pred2.getPredicate());
}
/*
* Overridden to set custom matching options. (non-Javadoc)
*
* @see
* org.eclipse.emf.compare.match.engine.GenericMatchEngine#updateSettings
* (org.eclipse.emf.compare.match.engine.MatchSettings, java.util.Map)
*/
@Override
protected void updateSettings(MatchSettings settings,
Map<String, Object> optionMap) {
super.updateSettings(settings, optionMap);
Map<String, Object> ignoreOptions = new HashMap<String, Object>();
// don't compare by IDs as these can be not unique in current EMF of
// EventB
// FIXME: this can be removed if EMF is fixed to support unique IDs
ignoreOptions.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
ignoreOptions.put(MatchOptions.OPTION_IGNORE_ID, true);
super.updateSettings(settings, ignoreOptions);
}
@SuppressWarnings("unchecked")
@Override
protected <T> T getOption(final String key) throws ClassCastException {
if (options.containsKey(key)) {
return (T) options.get(key);
} else {
return (T) defaultOptions.get(key);
}
}
private String getName(final EObject object) {
/*
* Make sure correct names for EventBNamed elements are used.
*/
if (object instanceof EventBNamed) {
return ((EventBNamed) object).getName();
}
// fallback to default
try {
return NameSimilarity.findName(object);
} catch (final FactoryException e) {
return null;
}
}
private boolean areSameType(final EObject obj1, final EObject obj2) {
return obj1 != null && obj2 != null
&& obj1.eClass().equals(obj2.eClass());
}
/**
* Test if both given {@link EObject}s are {@link EventBComponent}s and of
* same type of component, includes <code>null</code> check.
*
* @param obj1
* @param obj2
* @return
*/
private boolean areSameComponentType(final EObject obj1, final EObject obj2) {
return areSameType(obj1, obj2)
&& obj1 instanceof EventBNamedCommentedComponentElement;
}
/**
* Test if both given {@link EObject}s are of type {@link Variant}, includes
* <code>null</code> check.
*
* @param obj1
* @param obj2
* @return
*/
private boolean areVariants(final EObject obj1, final EObject obj2) {
return areSameType(obj1, obj2) && obj2 instanceof Variant;
}
}