From 250722c453223a238192fda8db9e692ea776afc7 Mon Sep 17 00:00:00 2001 From: ArenBabikian Date: Sun, 19 May 2019 04:57:59 -0400 Subject: REALMET: first impl of n'hood visualis. minor bug with adding outgng 0s. --- .../metrics/examples/CSERposterSample.xtend | 76 +++++ .../src/linkedList/Element.java | 77 +++++ .../src/linkedList/LinkedListFactory.java | 60 ++++ .../src/linkedList/LinkedListPackage.java | 312 +++++++++++++++++++++ .../src/linkedList/List.java | 50 ++++ .../src/linkedList/Object.java | 19 ++ .../src/linkedList/impl/ElementImpl.java | 241 ++++++++++++++++ .../src/linkedList/impl/LinkedListFactoryImpl.java | 120 ++++++++ .../src/linkedList/impl/LinkedListPackageImpl.java | 239 ++++++++++++++++ .../src/linkedList/impl/ListImpl.java | 176 ++++++++++++ .../src/linkedList/impl/ObjectImpl.java | 36 +++ .../linkedList/util/LinkedListAdapterFactory.java | 158 +++++++++++ .../src/linkedList/util/LinkedListSwitch.java | 154 ++++++++++ 13 files changed, 1718 insertions(+) create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Element.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListFactory.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListPackage.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/List.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Object.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ElementImpl.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListFactoryImpl.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListPackageImpl.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ListImpl.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ObjectImpl.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListAdapterFactory.java create mode 100644 Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListSwitch.java (limited to 'Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src') diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend new file mode 100644 index 00000000..8dd16090 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend @@ -0,0 +1,76 @@ +package ca.mcgill.ecse.dslreasoner.realistic.metrics.examples + +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration +import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2PartialInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml +import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace +import java.util.Collections +import org.eclipse.emf.ecore.EClass +import org.eclipse.emf.ecore.EEnum +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl +import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine +import java.io.PrintWriter +import linkedList.LinkedListPackage +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.Neighbourhood2Gml + +class CSERposterSample { + static val partialInterpretation2Logic = new InstanceModel2PartialInterpretation + static val neighbourhoodComputer = new PartialInterpretation2ImmutableTypeLattice + static val Ecore2Logic ecore2Logic = new Ecore2Logic + static val partialVisualizer = new PartialInterpretation2Gml + static val neighbourhoodVisualizer = new Neighbourhood2Gml + static val depth = 1 + + def static void main(String[] args) { + Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*", new XMIResourceFactoryImpl) + YakindummPackage.eINSTANCE.eClass + LinkedListPackage.eINSTANCE.eClass + ReteEngine.getClass + + val outputs = "outputs" + val instModName = "realisticModel" + val workspace = new FileSystemWorkspace('''resources''', "") + val model = workspace.readModel(EObject, instModName+".xmi") + + val pckg = model.eClass.EPackage + val metamodel = new EcoreMetamodelDescriptor( + pckg.EClassifiers.filter(EClass).toList, + Collections::emptySet, + false, + pckg.EClassifiers.filter(EEnum).toList, + pckg.EClassifiers.filter(EEnum).map[ELiterals].flatten.toList, + pckg.EClassifiers.filter(EClass).map[EReferences].flatten.toList, + pckg.EClassifiers.filter(EClass).map[EAttributes].flatten.toList + ) + val metamodelTransformationOutput = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration) + + val partialModelOutput = partialInterpretation2Logic.transform(metamodelTransformationOutput, model.eResource, false) + + val writer = new PrintWriter(outputs+"//"+instModName+"MODEL.gml") + + writer.print(partialVisualizer.transform(partialModelOutput)) + + writer.close + + val hood = neighbourhoodComputer.createRepresentation(partialModelOutput, depth, Integer.MAX_VALUE, Integer.MAX_VALUE) + + val w2 = new PrintWriter(outputs+"/"+instModName+"NEIGHBOURHOOD.gml") + + w2.print(neighbourhoodVisualizer.transform(hood, partialModelOutput)) + + w2.close + + println("visualization done") + +// partialModelOutput.openWorldElements + //RESULTS +// print(hood) + + } +} diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Element.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Element.java new file mode 100644 index 00000000..463523f0 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Element.java @@ -0,0 +1,77 @@ +/** + */ +package linkedList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Element'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see linkedList.LinkedListPackage#getElement() + * @model + * @generated + */ +public interface Element extends EObject { + /** + * Returns the value of the 'Value' containment reference. + * + *

+ * If the meaning of the 'Value' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Value' containment reference. + * @see #setValue(linkedList.Object) + * @see linkedList.LinkedListPackage#getElement_Value() + * @model containment="true" required="true" + * @generated + */ + linkedList.Object getValue(); + + /** + * Sets the value of the '{@link linkedList.Element#getValue Value}' containment reference. + * + * + * @param value the new value of the 'Value' containment reference. + * @see #getValue() + * @generated + */ + void setValue(linkedList.Object value); + + /** + * Returns the value of the 'Next' containment reference. + * + *

+ * If the meaning of the 'Next' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Next' containment reference. + * @see #setNext(Element) + * @see linkedList.LinkedListPackage#getElement_Next() + * @model containment="true" + * @generated + */ + Element getNext(); + + /** + * Sets the value of the '{@link linkedList.Element#getNext Next}' containment reference. + * + * + * @param value the new value of the 'Next' containment reference. + * @see #getNext() + * @generated + */ + void setNext(Element value); + +} // Element diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListFactory.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListFactory.java new file mode 100644 index 00000000..8ef9cd8d --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListFactory.java @@ -0,0 +1,60 @@ +/** + */ +package linkedList; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see linkedList.LinkedListPackage + * @generated + */ +public interface LinkedListFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + LinkedListFactory eINSTANCE = linkedList.impl.LinkedListFactoryImpl.init(); + + /** + * Returns a new object of class 'List'. + * + * + * @return a new object of class 'List'. + * @generated + */ + List createList(); + + /** + * Returns a new object of class 'Element'. + * + * + * @return a new object of class 'Element'. + * @generated + */ + Element createElement(); + + /** + * Returns a new object of class 'Object'. + * + * + * @return a new object of class 'Object'. + * @generated + */ + Object createObject(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + LinkedListPackage getLinkedListPackage(); + +} //LinkedListFactory diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListPackage.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListPackage.java new file mode 100644 index 00000000..06a47d87 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/LinkedListPackage.java @@ -0,0 +1,312 @@ +/** + */ +package linkedList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + * + * + * @see linkedList.LinkedListFactory + * @model kind="package" + * @generated + */ +public interface LinkedListPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "linkedList"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "llmm"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "LLMM"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + LinkedListPackage eINSTANCE = linkedList.impl.LinkedListPackageImpl.init(); + + /** + * The meta object id for the '{@link linkedList.impl.ListImpl List}' class. + * + * + * @see linkedList.impl.ListImpl + * @see linkedList.impl.LinkedListPackageImpl#getList() + * @generated + */ + int LIST = 0; + + /** + * The feature id for the 'First' containment reference. + * + * + * @generated + * @ordered + */ + int LIST__FIRST = 0; + + /** + * The number of structural features of the 'List' class. + * + * + * @generated + * @ordered + */ + int LIST_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'List' class. + * + * + * @generated + * @ordered + */ + int LIST_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link linkedList.impl.ElementImpl Element}' class. + * + * + * @see linkedList.impl.ElementImpl + * @see linkedList.impl.LinkedListPackageImpl#getElement() + * @generated + */ + int ELEMENT = 1; + + /** + * The feature id for the 'Value' containment reference. + * + * + * @generated + * @ordered + */ + int ELEMENT__VALUE = 0; + + /** + * The feature id for the 'Next' containment reference. + * + * + * @generated + * @ordered + */ + int ELEMENT__NEXT = 1; + + /** + * The number of structural features of the 'Element' class. + * + * + * @generated + * @ordered + */ + int ELEMENT_FEATURE_COUNT = 2; + + /** + * The number of operations of the 'Element' class. + * + * + * @generated + * @ordered + */ + int ELEMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link linkedList.impl.ObjectImpl Object}' class. + * + * + * @see linkedList.impl.ObjectImpl + * @see linkedList.impl.LinkedListPackageImpl#getObject() + * @generated + */ + int OBJECT = 2; + + /** + * The number of structural features of the 'Object' class. + * + * + * @generated + * @ordered + */ + int OBJECT_FEATURE_COUNT = 0; + + /** + * The number of operations of the 'Object' class. + * + * + * @generated + * @ordered + */ + int OBJECT_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link linkedList.List List}'. + * + * + * @return the meta object for class 'List'. + * @see linkedList.List + * @generated + */ + EClass getList(); + + /** + * Returns the meta object for the containment reference '{@link linkedList.List#getFirst First}'. + * + * + * @return the meta object for the containment reference 'First'. + * @see linkedList.List#getFirst() + * @see #getList() + * @generated + */ + EReference getList_First(); + + /** + * Returns the meta object for class '{@link linkedList.Element Element}'. + * + * + * @return the meta object for class 'Element'. + * @see linkedList.Element + * @generated + */ + EClass getElement(); + + /** + * Returns the meta object for the containment reference '{@link linkedList.Element#getValue Value}'. + * + * + * @return the meta object for the containment reference 'Value'. + * @see linkedList.Element#getValue() + * @see #getElement() + * @generated + */ + EReference getElement_Value(); + + /** + * Returns the meta object for the containment reference '{@link linkedList.Element#getNext Next}'. + * + * + * @return the meta object for the containment reference 'Next'. + * @see linkedList.Element#getNext() + * @see #getElement() + * @generated + */ + EReference getElement_Next(); + + /** + * Returns the meta object for class '{@link linkedList.Object Object}'. + * + * + * @return the meta object for class 'Object'. + * @see linkedList.Object + * @generated + */ + EClass getObject(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + LinkedListFactory getLinkedListFactory(); + + /** + * + * Defines literals for the meta objects that represent + * + * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link linkedList.impl.ListImpl List}' class. + * + * + * @see linkedList.impl.ListImpl + * @see linkedList.impl.LinkedListPackageImpl#getList() + * @generated + */ + EClass LIST = eINSTANCE.getList(); + + /** + * The meta object literal for the 'First' containment reference feature. + * + * + * @generated + */ + EReference LIST__FIRST = eINSTANCE.getList_First(); + + /** + * The meta object literal for the '{@link linkedList.impl.ElementImpl Element}' class. + * + * + * @see linkedList.impl.ElementImpl + * @see linkedList.impl.LinkedListPackageImpl#getElement() + * @generated + */ + EClass ELEMENT = eINSTANCE.getElement(); + + /** + * The meta object literal for the 'Value' containment reference feature. + * + * + * @generated + */ + EReference ELEMENT__VALUE = eINSTANCE.getElement_Value(); + + /** + * The meta object literal for the 'Next' containment reference feature. + * + * + * @generated + */ + EReference ELEMENT__NEXT = eINSTANCE.getElement_Next(); + + /** + * The meta object literal for the '{@link linkedList.impl.ObjectImpl Object}' class. + * + * + * @see linkedList.impl.ObjectImpl + * @see linkedList.impl.LinkedListPackageImpl#getObject() + * @generated + */ + EClass OBJECT = eINSTANCE.getObject(); + + } + +} //LinkedListPackage diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/List.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/List.java new file mode 100644 index 00000000..a72cc711 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/List.java @@ -0,0 +1,50 @@ +/** + */ +package linkedList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'List'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see linkedList.LinkedListPackage#getList() + * @model + * @generated + */ +public interface List extends EObject { + /** + * Returns the value of the 'First' containment reference. + * + *

+ * If the meaning of the 'First' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'First' containment reference. + * @see #setFirst(Element) + * @see linkedList.LinkedListPackage#getList_First() + * @model containment="true" + * @generated + */ + Element getFirst(); + + /** + * Sets the value of the '{@link linkedList.List#getFirst First}' containment reference. + * + * + * @param value the new value of the 'First' containment reference. + * @see #getFirst() + * @generated + */ + void setFirst(Element value); + +} // List diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Object.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Object.java new file mode 100644 index 00000000..4c8d1081 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/Object.java @@ -0,0 +1,19 @@ +/** + */ +package linkedList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Object'. + * + * + * + * @see linkedList.LinkedListPackage#getObject() + * @model + * @generated + */ +public interface Object extends EObject { + +} // Object diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ElementImpl.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ElementImpl.java new file mode 100644 index 00000000..d08f707b --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ElementImpl.java @@ -0,0 +1,241 @@ +/** + */ +package linkedList.impl; + +import linkedList.Element; +import linkedList.LinkedListPackage; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Element'. + * + *

+ * The following features are implemented: + *

+ * + * + * @generated + */ +public class ElementImpl extends MinimalEObjectImpl.Container implements Element { + /** + * The cached value of the '{@link #getValue() Value}' containment reference. + * + * + * @see #getValue() + * @generated + * @ordered + */ + protected linkedList.Object value; + + /** + * The cached value of the '{@link #getNext() Next}' containment reference. + * + * + * @see #getNext() + * @generated + * @ordered + */ + protected Element next; + + /** + * + * + * @generated + */ + protected ElementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return LinkedListPackage.Literals.ELEMENT; + } + + /** + * + * + * @generated + */ + public linkedList.Object getValue() { + return value; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetValue(linkedList.Object newValue, NotificationChain msgs) { + linkedList.Object oldValue = value; + value = newValue; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LinkedListPackage.ELEMENT__VALUE, oldValue, newValue); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setValue(linkedList.Object newValue) { + if (newValue != value) { + NotificationChain msgs = null; + if (value != null) + msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LinkedListPackage.ELEMENT__VALUE, null, msgs); + if (newValue != null) + msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LinkedListPackage.ELEMENT__VALUE, null, msgs); + msgs = basicSetValue(newValue, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, LinkedListPackage.ELEMENT__VALUE, newValue, newValue)); + } + + /** + * + * + * @generated + */ + public Element getNext() { + return next; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetNext(Element newNext, NotificationChain msgs) { + Element oldNext = next; + next = newNext; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LinkedListPackage.ELEMENT__NEXT, oldNext, newNext); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setNext(Element newNext) { + if (newNext != next) { + NotificationChain msgs = null; + if (next != null) + msgs = ((InternalEObject)next).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LinkedListPackage.ELEMENT__NEXT, null, msgs); + if (newNext != null) + msgs = ((InternalEObject)newNext).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LinkedListPackage.ELEMENT__NEXT, null, msgs); + msgs = basicSetNext(newNext, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, LinkedListPackage.ELEMENT__NEXT, newNext, newNext)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case LinkedListPackage.ELEMENT__VALUE: + return basicSetValue(null, msgs); + case LinkedListPackage.ELEMENT__NEXT: + return basicSetNext(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case LinkedListPackage.ELEMENT__VALUE: + return getValue(); + case LinkedListPackage.ELEMENT__NEXT: + return getNext(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case LinkedListPackage.ELEMENT__VALUE: + setValue((linkedList.Object)newValue); + return; + case LinkedListPackage.ELEMENT__NEXT: + setNext((Element)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case LinkedListPackage.ELEMENT__VALUE: + setValue((linkedList.Object)null); + return; + case LinkedListPackage.ELEMENT__NEXT: + setNext((Element)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case LinkedListPackage.ELEMENT__VALUE: + return value != null; + case LinkedListPackage.ELEMENT__NEXT: + return next != null; + } + return super.eIsSet(featureID); + } + +} //ElementImpl diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListFactoryImpl.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListFactoryImpl.java new file mode 100644 index 00000000..1a66a5e4 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListFactoryImpl.java @@ -0,0 +1,120 @@ +/** + */ +package linkedList.impl; + +import linkedList.Element; +import linkedList.LinkedListFactory; +import linkedList.LinkedListPackage; +import linkedList.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class LinkedListFactoryImpl extends EFactoryImpl implements LinkedListFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static LinkedListFactory init() { + try { + LinkedListFactory theLinkedListFactory = (LinkedListFactory)EPackage.Registry.INSTANCE.getEFactory(LinkedListPackage.eNS_URI); + if (theLinkedListFactory != null) { + return theLinkedListFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new LinkedListFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public LinkedListFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case LinkedListPackage.LIST: return createList(); + case LinkedListPackage.ELEMENT: return createElement(); + case LinkedListPackage.OBJECT: return createObject(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public List createList() { + ListImpl list = new ListImpl(); + return list; + } + + /** + * + * + * @generated + */ + public Element createElement() { + ElementImpl element = new ElementImpl(); + return element; + } + + /** + * + * + * @generated + */ + public linkedList.Object createObject() { + ObjectImpl object = new ObjectImpl(); + return object; + } + + /** + * + * + * @generated + */ + public LinkedListPackage getLinkedListPackage() { + return (LinkedListPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static LinkedListPackage getPackage() { + return LinkedListPackage.eINSTANCE; + } + +} //LinkedListFactoryImpl diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListPackageImpl.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListPackageImpl.java new file mode 100644 index 00000000..f190c4d0 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/LinkedListPackageImpl.java @@ -0,0 +1,239 @@ +/** + */ +package linkedList.impl; + +import linkedList.Element; +import linkedList.LinkedListFactory; +import linkedList.LinkedListPackage; +import linkedList.List; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class LinkedListPackageImpl extends EPackageImpl implements LinkedListPackage { + /** + * + * + * @generated + */ + private EClass listEClass = null; + + /** + * + * + * @generated + */ + private EClass elementEClass = null; + + /** + * + * + * @generated + */ + private EClass objectEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see linkedList.LinkedListPackage#eNS_URI + * @see #init() + * @generated + */ + private LinkedListPackageImpl() { + super(eNS_URI, LinkedListFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link LinkedListPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static LinkedListPackage init() { + if (isInited) return (LinkedListPackage)EPackage.Registry.INSTANCE.getEPackage(LinkedListPackage.eNS_URI); + + // Obtain or create and register package + Object registeredLinkedListPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + LinkedListPackageImpl theLinkedListPackage = registeredLinkedListPackage instanceof LinkedListPackageImpl ? (LinkedListPackageImpl)registeredLinkedListPackage : new LinkedListPackageImpl(); + + isInited = true; + + // Create package meta-data objects + theLinkedListPackage.createPackageContents(); + + // Initialize created meta-data + theLinkedListPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theLinkedListPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(LinkedListPackage.eNS_URI, theLinkedListPackage); + return theLinkedListPackage; + } + + /** + * + * + * @generated + */ + public EClass getList() { + return listEClass; + } + + /** + * + * + * @generated + */ + public EReference getList_First() { + return (EReference)listEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getElement() { + return elementEClass; + } + + /** + * + * + * @generated + */ + public EReference getElement_Value() { + return (EReference)elementEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getElement_Next() { + return (EReference)elementEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getObject() { + return objectEClass; + } + + /** + * + * + * @generated + */ + public LinkedListFactory getLinkedListFactory() { + return (LinkedListFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + listEClass = createEClass(LIST); + createEReference(listEClass, LIST__FIRST); + + elementEClass = createEClass(ELEMENT); + createEReference(elementEClass, ELEMENT__VALUE); + createEReference(elementEClass, ELEMENT__NEXT); + + objectEClass = createEClass(OBJECT); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(listEClass, List.class, "List", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getList_First(), this.getElement(), null, "first", null, 0, 1, List.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(elementEClass, Element.class, "Element", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getElement_Value(), this.getObject(), null, "value", null, 1, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getElement_Next(), this.getElement(), null, "next", null, 0, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(objectEClass, linkedList.Object.class, "Object", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} //LinkedListPackageImpl diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ListImpl.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ListImpl.java new file mode 100644 index 00000000..30d006cd --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ListImpl.java @@ -0,0 +1,176 @@ +/** + */ +package linkedList.impl; + +import linkedList.Element; +import linkedList.LinkedListPackage; +import linkedList.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'List'. + * + *

+ * The following features are implemented: + *

+ * + * + * @generated + */ +public class ListImpl extends MinimalEObjectImpl.Container implements List { + /** + * The cached value of the '{@link #getFirst() First}' containment reference. + * + * + * @see #getFirst() + * @generated + * @ordered + */ + protected Element first; + + /** + * + * + * @generated + */ + protected ListImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return LinkedListPackage.Literals.LIST; + } + + /** + * + * + * @generated + */ + public Element getFirst() { + return first; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetFirst(Element newFirst, NotificationChain msgs) { + Element oldFirst = first; + first = newFirst; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LinkedListPackage.LIST__FIRST, oldFirst, newFirst); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setFirst(Element newFirst) { + if (newFirst != first) { + NotificationChain msgs = null; + if (first != null) + msgs = ((InternalEObject)first).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LinkedListPackage.LIST__FIRST, null, msgs); + if (newFirst != null) + msgs = ((InternalEObject)newFirst).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LinkedListPackage.LIST__FIRST, null, msgs); + msgs = basicSetFirst(newFirst, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, LinkedListPackage.LIST__FIRST, newFirst, newFirst)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case LinkedListPackage.LIST__FIRST: + return basicSetFirst(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case LinkedListPackage.LIST__FIRST: + return getFirst(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case LinkedListPackage.LIST__FIRST: + setFirst((Element)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case LinkedListPackage.LIST__FIRST: + setFirst((Element)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case LinkedListPackage.LIST__FIRST: + return first != null; + } + return super.eIsSet(featureID); + } + +} //ListImpl diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ObjectImpl.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ObjectImpl.java new file mode 100644 index 00000000..c9b55c8d --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/impl/ObjectImpl.java @@ -0,0 +1,36 @@ +/** + */ +package linkedList.impl; + +import linkedList.LinkedListPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Object'. + * + * + * @generated + */ +public class ObjectImpl extends MinimalEObjectImpl.Container implements linkedList.Object { + /** + * + * + * @generated + */ + protected ObjectImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return LinkedListPackage.Literals.OBJECT; + } + +} //ObjectImpl diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListAdapterFactory.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListAdapterFactory.java new file mode 100644 index 00000000..583192ba --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListAdapterFactory.java @@ -0,0 +1,158 @@ +/** + */ +package linkedList.util; + +import linkedList.Element; +import linkedList.LinkedListPackage; +import linkedList.List; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see linkedList.LinkedListPackage + * @generated + */ +public class LinkedListAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static LinkedListPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public LinkedListAdapterFactory() { + if (modelPackage == null) { + modelPackage = LinkedListPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected LinkedListSwitch modelSwitch = + new LinkedListSwitch() { + @Override + public Adapter caseList(List object) { + return createListAdapter(); + } + @Override + public Adapter caseElement(Element object) { + return createElementAdapter(); + } + @Override + public Adapter caseObject(linkedList.Object object) { + return createObjectAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link linkedList.List List}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see linkedList.List + * @generated + */ + public Adapter createListAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link linkedList.Element Element}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see linkedList.Element + * @generated + */ + public Adapter createElementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link linkedList.Object Object}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see linkedList.Object + * @generated + */ + public Adapter createObjectAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //LinkedListAdapterFactory diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListSwitch.java b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListSwitch.java new file mode 100644 index 00000000..f5dcf560 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/linkedList/util/LinkedListSwitch.java @@ -0,0 +1,154 @@ +/** + */ +package linkedList.util; + +import linkedList.Element; +import linkedList.LinkedListPackage; +import linkedList.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see linkedList.LinkedListPackage + * @generated + */ +public class LinkedListSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static LinkedListPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public LinkedListSwitch() { + if (modelPackage == null) { + modelPackage = LinkedListPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case LinkedListPackage.LIST: { + List list = (List)theEObject; + T result = caseList(list); + if (result == null) result = defaultCase(theEObject); + return result; + } + case LinkedListPackage.ELEMENT: { + Element element = (Element)theEObject; + T result = caseElement(element); + if (result == null) result = defaultCase(theEObject); + return result; + } + case LinkedListPackage.OBJECT: { + linkedList.Object object = (linkedList.Object)theEObject; + T result = caseObject(object); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'List'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'List'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseList(List object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Element'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Element'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseElement(Element object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Object'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Object'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseObject(linkedList.Object object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //LinkedListSwitch -- cgit v1.2.3-54-g00ecf