diff options
author | Ed Willink | 2015-09-14 09:35:09 +0000 |
---|---|---|
committer | Ed Willink | 2015-09-14 09:45:08 +0000 |
commit | 8d372dbd5a5acbe15ea92262b8bf31e0fd04f43a (patch) | |
tree | b4ce20186d93258bdf3047328e0e0910cbb68381 | |
parent | 3f9a92d03c921b3df1ae9a507811a7fe9dfcfae6 (diff) | |
download | org.eclipse.ocl-8d372dbd5a5acbe15ea92262b8bf31e0fd04f43a.tar.gz org.eclipse.ocl-8d372dbd5a5acbe15ea92262b8bf31e0fd04f43a.tar.xz org.eclipse.ocl-8d372dbd5a5acbe15ea92262b8bf31e0fd04f43a.zip |
[477283] Ensure Complete Packages are created before their dummy content
38 files changed, 3209 insertions, 1 deletions
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java index b7afa7af42..49643ea6a6 100644 --- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java +++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java @@ -443,7 +443,7 @@ public class PivotMetamodelManager implements MetamodelManagerInternal.Metamodel for (int i = 0; i < candidateParameters.size(); i++) { Parameter referenceParameter = referenceParameters.get(i); Parameter candidateParameter = candidateParameters.get(i); - if ((referenceParameter == null) || (candidateParameter == null)) { // Doesn't happen (just a supurious NPE guard) + if ((referenceParameter == null) || (candidateParameter == null)) { // Doesn't happen (just a spurious NPE guard) referenceConformsToCandidate = false; candidateConformsToReference = false; } @@ -1157,6 +1157,9 @@ public class PivotMetamodelManager implements MetamodelManagerInternal.Metamodel } org.eclipse.ocl.pivot.Class thisOppositeClass; org.eclipse.ocl.pivot.Package thatPackage = thatClass.getOwningPackage(); + assert thatPackage != null; + completeModel.getCompletePackage(thatPackage); +// completeModel.getCompleteClass(thatClass); // FIXME BUG 477342 uncommenting this gives intermirttent dispose() ISEs List<org.eclipse.ocl.pivot.Package> thesePackages = thisModel.getOwnedPackages(); String thatPackageName = ClassUtil.nonNullModel(thatPackage.getName()); org.eclipse.ocl.pivot.Package thisOppositePackage = NameUtil.getNameable(thesePackages, thatPackageName); diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/A.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/A.java new file mode 100644 index 0000000000..8734ffda7e --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/A.java @@ -0,0 +1,18 @@ +/** + */ +package bug477283.a; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>A</b></em>'. + * <!-- end-user-doc --> + * + * + * @see bug477283.a.Bug477283APackage#getA() + * @model + * @generated + */ +public interface A extends EObject { +} // A diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/Bug477283AFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/Bug477283AFactory.java new file mode 100644 index 0000000000..6f05ae9bdc --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/Bug477283AFactory.java @@ -0,0 +1,42 @@ +/** + */ +package bug477283.a; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see bug477283.a.Bug477283APackage + * @generated + */ +public interface Bug477283AFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283AFactory eINSTANCE = bug477283.a.impl.Bug477283AFactoryImpl.init(); + + /** + * Returns a new object of class '<em>A</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>A</em>'. + * @generated + */ + A createA(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + Bug477283APackage getBug477283APackage(); + +} //Bug477283AFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/Bug477283APackage.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/Bug477283APackage.java new file mode 100644 index 0000000000..0943e3044e --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/Bug477283APackage.java @@ -0,0 +1,131 @@ +/** + */ +package bug477283.a; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see bug477283.a.Bug477283AFactory + * @model kind="package" + * @generated + */ +public interface Bug477283APackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "a"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.eclipse.org/ocl/Bug477283a"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "a"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283APackage eINSTANCE = bug477283.a.impl.Bug477283APackageImpl.init(); + + /** + * The meta object id for the '{@link bug477283.a.impl.AImpl <em>A</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.a.impl.AImpl + * @see bug477283.a.impl.Bug477283APackageImpl#getA() + * @generated + */ + int A = 0; + + /** + * The number of structural features of the '<em>A</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int A_FEATURE_COUNT = 0; + + /** + * The number of operations of the '<em>A</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int A_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link bug477283.a.A <em>A</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>A</em>'. + * @see bug477283.a.A + * @generated + */ + EClass getA(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + Bug477283AFactory getBug477283AFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link bug477283.a.impl.AImpl <em>A</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.a.impl.AImpl + * @see bug477283.a.impl.Bug477283APackageImpl#getA() + * @generated + */ + EClass A = eINSTANCE.getA(); + + } + +} //Bug477283APackage diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/ASub.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/ASub.java new file mode 100644 index 0000000000..7df81e0e5d --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/ASub.java @@ -0,0 +1,18 @@ +/** + */ +package bug477283.a.asub; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>ASub</b></em>'. + * <!-- end-user-doc --> + * + * + * @see bug477283.a.asub.Bug477283subPackage#getASub() + * @model + * @generated + */ +public interface ASub extends EObject { +} // ASub diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/Bug477283subFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/Bug477283subFactory.java new file mode 100644 index 0000000000..dbe01d4bdf --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/Bug477283subFactory.java @@ -0,0 +1,42 @@ +/** + */ +package bug477283.a.asub; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see bug477283.a.asub.Bug477283subPackage + * @generated + */ +public interface Bug477283subFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283subFactory eINSTANCE = bug477283.a.asub.impl.Bug477283subFactoryImpl.init(); + + /** + * Returns a new object of class '<em>ASub</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>ASub</em>'. + * @generated + */ + ASub createASub(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + Bug477283subPackage getBug477283subPackage(); + +} //Bug477283subFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/Bug477283subPackage.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/Bug477283subPackage.java new file mode 100644 index 0000000000..b7c64b99e6 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/Bug477283subPackage.java @@ -0,0 +1,131 @@ +/** + */ +package bug477283.a.asub; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see bug477283.a.asub.Bug477283subFactory + * @model kind="package" + * @generated + */ +public interface Bug477283subPackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "asub"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.eclipse.org/ocl/Bug477283asub"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "asub"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283subPackage eINSTANCE = bug477283.a.asub.impl.Bug477283subPackageImpl.init(); + + /** + * The meta object id for the '{@link bug477283.a.asub.impl.ASubImpl <em>ASub</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.a.asub.impl.ASubImpl + * @see bug477283.a.asub.impl.Bug477283subPackageImpl#getASub() + * @generated + */ + int ASUB = 0; + + /** + * The number of structural features of the '<em>ASub</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ASUB_FEATURE_COUNT = 0; + + /** + * The number of operations of the '<em>ASub</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ASUB_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link bug477283.a.asub.ASub <em>ASub</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>ASub</em>'. + * @see bug477283.a.asub.ASub + * @generated + */ + EClass getASub(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + Bug477283subFactory getBug477283subFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link bug477283.a.asub.impl.ASubImpl <em>ASub</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.a.asub.impl.ASubImpl + * @see bug477283.a.asub.impl.Bug477283subPackageImpl#getASub() + * @generated + */ + EClass ASUB = eINSTANCE.getASub(); + + } + +} //Bug477283subPackage diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/ASubSub.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/ASubSub.java new file mode 100644 index 0000000000..86ddb7c988 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/ASubSub.java @@ -0,0 +1,18 @@ +/** + */ +package bug477283.a.asub.asubsub; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>ASub Sub</b></em>'. + * <!-- end-user-doc --> + * + * + * @see bug477283.a.asub.asubsub.Bug477283AsubsubPackage#getASubSub() + * @model + * @generated + */ +public interface ASubSub extends EObject { +} // ASubSub diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/Bug477283AsubsubFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/Bug477283AsubsubFactory.java new file mode 100644 index 0000000000..2822779450 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/Bug477283AsubsubFactory.java @@ -0,0 +1,42 @@ +/** + */ +package bug477283.a.asub.asubsub; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see bug477283.a.asub.asubsub.Bug477283AsubsubPackage + * @generated + */ +public interface Bug477283AsubsubFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283AsubsubFactory eINSTANCE = bug477283.a.asub.asubsub.impl.Bug477283AsubsubFactoryImpl.init(); + + /** + * Returns a new object of class '<em>ASub Sub</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>ASub Sub</em>'. + * @generated + */ + ASubSub createASubSub(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + Bug477283AsubsubPackage getBug477283AsubsubPackage(); + +} //Bug477283AsubsubFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/Bug477283AsubsubPackage.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/Bug477283AsubsubPackage.java new file mode 100644 index 0000000000..e887ebe2e3 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/Bug477283AsubsubPackage.java @@ -0,0 +1,131 @@ +/** + */ +package bug477283.a.asub.asubsub; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see bug477283.a.asub.asubsub.Bug477283AsubsubFactory + * @model kind="package" + * @generated + */ +public interface Bug477283AsubsubPackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "asubsub"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.eclipse.org/ocl/Bug477283asubsub"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "asubsub"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283AsubsubPackage eINSTANCE = bug477283.a.asub.asubsub.impl.Bug477283AsubsubPackageImpl.init(); + + /** + * The meta object id for the '{@link bug477283.a.asub.asubsub.impl.ASubSubImpl <em>ASub Sub</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.a.asub.asubsub.impl.ASubSubImpl + * @see bug477283.a.asub.asubsub.impl.Bug477283AsubsubPackageImpl#getASubSub() + * @generated + */ + int ASUB_SUB = 0; + + /** + * The number of structural features of the '<em>ASub Sub</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ASUB_SUB_FEATURE_COUNT = 0; + + /** + * The number of operations of the '<em>ASub Sub</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ASUB_SUB_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link bug477283.a.asub.asubsub.ASubSub <em>ASub Sub</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>ASub Sub</em>'. + * @see bug477283.a.asub.asubsub.ASubSub + * @generated + */ + EClass getASubSub(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + Bug477283AsubsubFactory getBug477283AsubsubFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link bug477283.a.asub.asubsub.impl.ASubSubImpl <em>ASub Sub</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.a.asub.asubsub.impl.ASubSubImpl + * @see bug477283.a.asub.asubsub.impl.Bug477283AsubsubPackageImpl#getASubSub() + * @generated + */ + EClass ASUB_SUB = eINSTANCE.getASubSub(); + + } + +} //Bug477283AsubsubPackage diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/ASubSubImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/ASubSubImpl.java new file mode 100644 index 0000000000..5f64af57a2 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/ASubSubImpl.java @@ -0,0 +1,39 @@ +/** + */ +package bug477283.a.asub.asubsub.impl; + +import bug477283.a.asub.asubsub.ASubSub; +import bug477283.a.asub.asubsub.Bug477283AsubsubPackage; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>ASub Sub</b></em>'. + * <!-- end-user-doc --> + * + * @generated + */ +public class ASubSubImpl extends MinimalEObjectImpl.Container implements ASubSub { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ASubSubImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return Bug477283AsubsubPackage.Literals.ASUB_SUB; + } + +} //ASubSubImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/Bug477283AsubsubFactoryImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/Bug477283AsubsubFactoryImpl.java new file mode 100644 index 0000000000..d9d58d8195 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/Bug477283AsubsubFactoryImpl.java @@ -0,0 +1,95 @@ +/** + */ +package bug477283.a.asub.asubsub.impl; + +import bug477283.a.asub.asubsub.*; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283AsubsubFactoryImpl extends EFactoryImpl implements Bug477283AsubsubFactory { + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static Bug477283AsubsubFactory init() { + try { + Bug477283AsubsubFactory theBug477283AsubsubFactory = (Bug477283AsubsubFactory)EPackage.Registry.INSTANCE.getEFactory(Bug477283AsubsubPackage.eNS_URI); + if (theBug477283AsubsubFactory != null) { + return theBug477283AsubsubFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new Bug477283AsubsubFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AsubsubFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case Bug477283AsubsubPackage.ASUB_SUB: return createASubSub(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ASubSub createASubSub() { + ASubSubImpl aSubSub = new ASubSubImpl(); + return aSubSub; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AsubsubPackage getBug477283AsubsubPackage() { + return (Bug477283AsubsubPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static Bug477283AsubsubPackage getPackage() { + return Bug477283AsubsubPackage.eINSTANCE; + } + +} //Bug477283AsubsubFactoryImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/Bug477283AsubsubPackageImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/Bug477283AsubsubPackageImpl.java new file mode 100644 index 0000000000..c7ca5518b7 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/impl/Bug477283AsubsubPackageImpl.java @@ -0,0 +1,178 @@ +/** + */ +package bug477283.a.asub.asubsub.impl; + +import bug477283.a.Bug477283APackage; + +import bug477283.a.asub.Bug477283subPackage; + +import bug477283.a.asub.asubsub.ASubSub; +import bug477283.a.asub.asubsub.Bug477283AsubsubFactory; +import bug477283.a.asub.asubsub.Bug477283AsubsubPackage; + +import bug477283.a.asub.impl.Bug477283subPackageImpl; + +import bug477283.a.impl.Bug477283APackageImpl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283AsubsubPackageImpl extends EPackageImpl implements Bug477283AsubsubPackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass aSubSubEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see bug477283.a.asub.asubsub.Bug477283AsubsubPackage#eNS_URI + * @see #init() + * @generated + */ + private Bug477283AsubsubPackageImpl() { + super(eNS_URI, Bug477283AsubsubFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link Bug477283AsubsubPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static Bug477283AsubsubPackage init() { + if (isInited) return (Bug477283AsubsubPackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283AsubsubPackage.eNS_URI); + + // Obtain or create and register package + Bug477283AsubsubPackageImpl theBug477283AsubsubPackage = (Bug477283AsubsubPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof Bug477283AsubsubPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new Bug477283AsubsubPackageImpl()); + + isInited = true; + + // Obtain or create and register interdependencies + Bug477283APackageImpl theBug477283APackage = (Bug477283APackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Bug477283APackage.eNS_URI) instanceof Bug477283APackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Bug477283APackage.eNS_URI) : Bug477283APackage.eINSTANCE); + Bug477283subPackageImpl theBug477283subPackage = (Bug477283subPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI) instanceof Bug477283subPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI) : Bug477283subPackage.eINSTANCE); + + // Create package meta-data objects + theBug477283AsubsubPackage.createPackageContents(); + theBug477283APackage.createPackageContents(); + theBug477283subPackage.createPackageContents(); + + // Initialize created meta-data + theBug477283AsubsubPackage.initializePackageContents(); + theBug477283APackage.initializePackageContents(); + theBug477283subPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBug477283AsubsubPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(Bug477283AsubsubPackage.eNS_URI, theBug477283AsubsubPackage); + return theBug477283AsubsubPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getASubSub() { + return aSubSubEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AsubsubFactory getBug477283AsubsubFactory() { + return (Bug477283AsubsubFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + aSubSubEClass = createEClass(ASUB_SUB); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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(aSubSubEClass, ASubSub.class, "ASubSub", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + +} //Bug477283AsubsubPackageImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/util/Bug477283AsubsubAdapterFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/util/Bug477283AsubsubAdapterFactory.java new file mode 100644 index 0000000000..85ae9ab47f --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/util/Bug477283AsubsubAdapterFactory.java @@ -0,0 +1,120 @@ +/** + */ +package bug477283.a.asub.asubsub.util; + +import bug477283.a.asub.asubsub.*; + +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; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see bug477283.a.asub.asubsub.Bug477283AsubsubPackage + * @generated + */ +public class Bug477283AsubsubAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283AsubsubPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AsubsubAdapterFactory() { + if (modelPackage == null) { + modelPackage = Bug477283AsubsubPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @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 <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected Bug477283AsubsubSwitch<Adapter> modelSwitch = + new Bug477283AsubsubSwitch<Adapter>() { + @Override + public Adapter caseASubSub(ASubSub object) { + return createASubSubAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link bug477283.a.asub.asubsub.ASubSub <em>ASub Sub</em>}'. + * <!-- begin-user-doc --> + * 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. + * <!-- end-user-doc --> + * @return the new adapter. + * @see bug477283.a.asub.asubsub.ASubSub + * @generated + */ + public Adapter createASubSubAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //Bug477283AsubsubAdapterFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/util/Bug477283AsubsubSwitch.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/util/Bug477283AsubsubSwitch.java new file mode 100644 index 0000000000..71c0497573 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/asubsub/util/Bug477283AsubsubSwitch.java @@ -0,0 +1,110 @@ +/** + */ +package bug477283.a.asub.asubsub.util; + +import bug477283.a.asub.asubsub.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> 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. + * <!-- end-user-doc --> + * @see bug477283.a.asub.asubsub.Bug477283AsubsubPackage + * @generated + */ +public class Bug477283AsubsubSwitch<T> extends Switch<T> { + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283AsubsubPackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AsubsubSwitch() { + if (modelPackage == null) { + modelPackage = Bug477283AsubsubPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case Bug477283AsubsubPackage.ASUB_SUB: { + ASubSub aSubSub = (ASubSub)theEObject; + T result = caseASubSub(aSubSub); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>ASub Sub</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>ASub Sub</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseASubSub(ASubSub object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //Bug477283AsubsubSwitch diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/ASubImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/ASubImpl.java new file mode 100644 index 0000000000..9729ed1140 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/ASubImpl.java @@ -0,0 +1,39 @@ +/** + */ +package bug477283.a.asub.impl; + +import bug477283.a.asub.ASub; +import bug477283.a.asub.Bug477283subPackage; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>ASub</b></em>'. + * <!-- end-user-doc --> + * + * @generated + */ +public class ASubImpl extends MinimalEObjectImpl.Container implements ASub { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ASubImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return Bug477283subPackage.Literals.ASUB; + } + +} //ASubImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/Bug477283subFactoryImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/Bug477283subFactoryImpl.java new file mode 100644 index 0000000000..62acd74c23 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/Bug477283subFactoryImpl.java @@ -0,0 +1,95 @@ +/** + */ +package bug477283.a.asub.impl; + +import bug477283.a.asub.*; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283subFactoryImpl extends EFactoryImpl implements Bug477283subFactory { + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static Bug477283subFactory init() { + try { + Bug477283subFactory theBug477283subFactory = (Bug477283subFactory)EPackage.Registry.INSTANCE.getEFactory(Bug477283subPackage.eNS_URI); + if (theBug477283subFactory != null) { + return theBug477283subFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new Bug477283subFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283subFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case Bug477283subPackage.ASUB: return createASub(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ASub createASub() { + ASubImpl aSub = new ASubImpl(); + return aSub; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283subPackage getBug477283subPackage() { + return (Bug477283subPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static Bug477283subPackage getPackage() { + return Bug477283subPackage.eINSTANCE; + } + +} //Bug477283subFactoryImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/Bug477283subPackageImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/Bug477283subPackageImpl.java new file mode 100644 index 0000000000..a59dc04a3d --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/impl/Bug477283subPackageImpl.java @@ -0,0 +1,184 @@ +/** + */ +package bug477283.a.asub.impl; + +import bug477283.a.Bug477283APackage; + +import bug477283.a.asub.ASub; +import bug477283.a.asub.Bug477283subFactory; +import bug477283.a.asub.Bug477283subPackage; + +import bug477283.a.asub.asubsub.Bug477283AsubsubPackage; + +import bug477283.a.asub.asubsub.impl.Bug477283AsubsubPackageImpl; + +import bug477283.a.impl.Bug477283APackageImpl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283subPackageImpl extends EPackageImpl implements Bug477283subPackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass aSubEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see bug477283.a.asub.Bug477283subPackage#eNS_URI + * @see #init() + * @generated + */ + private Bug477283subPackageImpl() { + super(eNS_URI, Bug477283subFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link Bug477283subPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static Bug477283subPackage init() { + if (isInited) return (Bug477283subPackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI); + + // Obtain or create and register package + Bug477283subPackageImpl theBug477283subPackage = (Bug477283subPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof Bug477283subPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new Bug477283subPackageImpl()); + + isInited = true; + + // Obtain or create and register interdependencies + Bug477283APackageImpl theBug477283APackage = (Bug477283APackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Bug477283APackage.eNS_URI) instanceof Bug477283APackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Bug477283APackage.eNS_URI) : Bug477283APackage.eINSTANCE); + Bug477283AsubsubPackageImpl theBug477283AsubsubPackage = (Bug477283AsubsubPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Bug477283AsubsubPackage.eNS_URI) instanceof Bug477283AsubsubPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Bug477283AsubsubPackage.eNS_URI) : Bug477283AsubsubPackage.eINSTANCE); + + // Create package meta-data objects + theBug477283subPackage.createPackageContents(); + theBug477283APackage.createPackageContents(); + theBug477283AsubsubPackage.createPackageContents(); + + // Initialize created meta-data + theBug477283subPackage.initializePackageContents(); + theBug477283APackage.initializePackageContents(); + theBug477283AsubsubPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBug477283subPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(Bug477283subPackage.eNS_URI, theBug477283subPackage); + return theBug477283subPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getASub() { + return aSubEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283subFactory getBug477283subFactory() { + return (Bug477283subFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + aSubEClass = createEClass(ASUB); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + Bug477283AsubsubPackage theBug477283AsubsubPackage = (Bug477283AsubsubPackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283AsubsubPackage.eNS_URI); + + // Add subpackages + getESubpackages().add(theBug477283AsubsubPackage); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(aSubEClass, ASub.class, "ASub", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + +} //Bug477283subPackageImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/util/Bug477283subAdapterFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/util/Bug477283subAdapterFactory.java new file mode 100644 index 0000000000..132e8924a1 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/util/Bug477283subAdapterFactory.java @@ -0,0 +1,120 @@ +/** + */ +package bug477283.a.asub.util; + +import bug477283.a.asub.*; + +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; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see bug477283.a.asub.Bug477283subPackage + * @generated + */ +public class Bug477283subAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283subPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283subAdapterFactory() { + if (modelPackage == null) { + modelPackage = Bug477283subPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @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 <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected Bug477283subSwitch<Adapter> modelSwitch = + new Bug477283subSwitch<Adapter>() { + @Override + public Adapter caseASub(ASub object) { + return createASubAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link bug477283.a.asub.ASub <em>ASub</em>}'. + * <!-- begin-user-doc --> + * 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. + * <!-- end-user-doc --> + * @return the new adapter. + * @see bug477283.a.asub.ASub + * @generated + */ + public Adapter createASubAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //Bug477283subAdapterFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/util/Bug477283subSwitch.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/util/Bug477283subSwitch.java new file mode 100644 index 0000000000..d2ebcb8093 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/asub/util/Bug477283subSwitch.java @@ -0,0 +1,110 @@ +/** + */ +package bug477283.a.asub.util; + +import bug477283.a.asub.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> 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. + * <!-- end-user-doc --> + * @see bug477283.a.asub.Bug477283subPackage + * @generated + */ +public class Bug477283subSwitch<T> extends Switch<T> { + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283subPackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283subSwitch() { + if (modelPackage == null) { + modelPackage = Bug477283subPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case Bug477283subPackage.ASUB: { + ASub aSub = (ASub)theEObject; + T result = caseASub(aSub); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>ASub</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>ASub</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseASub(ASub object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //Bug477283subSwitch diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/AImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/AImpl.java new file mode 100644 index 0000000000..f4d4549560 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/AImpl.java @@ -0,0 +1,39 @@ +/** + */ +package bug477283.a.impl; + +import bug477283.a.A; +import bug477283.a.Bug477283APackage; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>A</b></em>'. + * <!-- end-user-doc --> + * + * @generated + */ +public class AImpl extends MinimalEObjectImpl.Container implements A { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected AImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return Bug477283APackage.Literals.A; + } + +} //AImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/Bug477283AFactoryImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/Bug477283AFactoryImpl.java new file mode 100644 index 0000000000..69b6f5ee67 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/Bug477283AFactoryImpl.java @@ -0,0 +1,95 @@ +/** + */ +package bug477283.a.impl; + +import bug477283.a.*; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283AFactoryImpl extends EFactoryImpl implements Bug477283AFactory { + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static Bug477283AFactory init() { + try { + Bug477283AFactory theBug477283AFactory = (Bug477283AFactory)EPackage.Registry.INSTANCE.getEFactory(Bug477283APackage.eNS_URI); + if (theBug477283AFactory != null) { + return theBug477283AFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new Bug477283AFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case Bug477283APackage.A: return createA(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public A createA() { + AImpl a = new AImpl(); + return a; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283APackage getBug477283APackage() { + return (Bug477283APackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static Bug477283APackage getPackage() { + return Bug477283APackage.eINSTANCE; + } + +} //Bug477283AFactoryImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/Bug477283APackageImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/Bug477283APackageImpl.java new file mode 100644 index 0000000000..b1892923b2 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/impl/Bug477283APackageImpl.java @@ -0,0 +1,186 @@ +/** + */ +package bug477283.a.impl; + +import bug477283.a.Bug477283AFactory; +import bug477283.a.Bug477283APackage; + +import bug477283.a.asub.Bug477283subPackage; + +import bug477283.a.asub.asubsub.Bug477283AsubsubPackage; + +import bug477283.a.asub.asubsub.impl.Bug477283AsubsubPackageImpl; + +import bug477283.a.asub.impl.Bug477283subPackageImpl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283APackageImpl extends EPackageImpl implements Bug477283APackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass aEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see bug477283.a.Bug477283APackage#eNS_URI + * @see #init() + * @generated + */ + private Bug477283APackageImpl() { + super(eNS_URI, Bug477283AFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link Bug477283APackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static Bug477283APackage init() { + if (isInited) return (Bug477283APackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283APackage.eNS_URI); + + // Obtain or create and register package + Bug477283APackageImpl theBug477283APackage = (Bug477283APackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof Bug477283APackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new Bug477283APackageImpl()); + + isInited = true; + + // Obtain or create and register interdependencies + Bug477283subPackageImpl theBug477283subPackage = (Bug477283subPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI) instanceof Bug477283subPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI) : Bug477283subPackage.eINSTANCE); + Bug477283AsubsubPackageImpl theBug477283AsubsubPackage = (Bug477283AsubsubPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Bug477283AsubsubPackage.eNS_URI) instanceof Bug477283AsubsubPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Bug477283AsubsubPackage.eNS_URI) : Bug477283AsubsubPackage.eINSTANCE); + + // Create package meta-data objects + theBug477283APackage.createPackageContents(); + theBug477283subPackage.createPackageContents(); + theBug477283AsubsubPackage.createPackageContents(); + + // Initialize created meta-data + theBug477283APackage.initializePackageContents(); + theBug477283subPackage.initializePackageContents(); + theBug477283AsubsubPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBug477283APackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(Bug477283APackage.eNS_URI, theBug477283APackage); + return theBug477283APackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getA() { + return aEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AFactory getBug477283AFactory() { + return (Bug477283AFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + aEClass = createEClass(A); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + Bug477283subPackage theBug477283subPackage = (Bug477283subPackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI); + + // Add subpackages + getESubpackages().add(theBug477283subPackage); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(aEClass, bug477283.a.A.class, "A", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} //Bug477283APackageImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/util/Bug477283AAdapterFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/util/Bug477283AAdapterFactory.java new file mode 100644 index 0000000000..6b84d1b0fc --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/util/Bug477283AAdapterFactory.java @@ -0,0 +1,120 @@ +/** + */ +package bug477283.a.util; + +import bug477283.a.*; + +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; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see bug477283.a.Bug477283APackage + * @generated + */ +public class Bug477283AAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283APackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283AAdapterFactory() { + if (modelPackage == null) { + modelPackage = Bug477283APackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @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 <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected Bug477283ASwitch<Adapter> modelSwitch = + new Bug477283ASwitch<Adapter>() { + @Override + public Adapter caseA(A object) { + return createAAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link bug477283.a.A <em>A</em>}'. + * <!-- begin-user-doc --> + * 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. + * <!-- end-user-doc --> + * @return the new adapter. + * @see bug477283.a.A + * @generated + */ + public Adapter createAAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //Bug477283AAdapterFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/util/Bug477283ASwitch.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/util/Bug477283ASwitch.java new file mode 100644 index 0000000000..983df667b0 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/a/util/Bug477283ASwitch.java @@ -0,0 +1,110 @@ +/** + */ +package bug477283.a.util; + +import bug477283.a.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> 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. + * <!-- end-user-doc --> + * @see bug477283.a.Bug477283APackage + * @generated + */ +public class Bug477283ASwitch<T> extends Switch<T> { + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283APackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283ASwitch() { + if (modelPackage == null) { + modelPackage = Bug477283APackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case Bug477283APackage.A: { + A a = (A)theEObject; + T result = caseA(a); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>A</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>A</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseA(A object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //Bug477283ASwitch diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/B.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/B.java new file mode 100644 index 0000000000..a984240dd7 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/B.java @@ -0,0 +1,52 @@ +/** + */ +package bug477283.b; + +import bug477283.a.asub.ASub; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>B</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * </p> + * <ul> + * <li>{@link bug477283.b.B#getRef <em>Ref</em>}</li> + * </ul> + * + * @see bug477283.b.Bug477283BPackage#getB() + * @model + * @generated + */ +public interface B extends EObject { + /** + * Returns the value of the '<em><b>Ref</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Ref</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Ref</em>' reference. + * @see #setRef(ASub) + * @see bug477283.b.Bug477283BPackage#getB_Ref() + * @model + * @generated + */ + ASub getRef(); + + /** + * Sets the value of the '{@link bug477283.b.B#getRef <em>Ref</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Ref</em>' reference. + * @see #getRef() + * @generated + */ + void setRef(ASub value); + +} // B diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/Bug477283BFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/Bug477283BFactory.java new file mode 100644 index 0000000000..e82ed8246c --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/Bug477283BFactory.java @@ -0,0 +1,42 @@ +/** + */ +package bug477283.b; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see bug477283.b.Bug477283BPackage + * @generated + */ +public interface Bug477283BFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283BFactory eINSTANCE = bug477283.b.impl.Bug477283BFactoryImpl.init(); + + /** + * Returns a new object of class '<em>B</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>B</em>'. + * @generated + */ + B createB(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + Bug477283BPackage getBug477283BPackage(); + +} //Bug477283BFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/Bug477283BPackage.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/Bug477283BPackage.java new file mode 100644 index 0000000000..b653d10903 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/Bug477283BPackage.java @@ -0,0 +1,160 @@ +/** + */ +package bug477283.b; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see bug477283.b.Bug477283BFactory + * @model kind="package" + * @generated + */ +public interface Bug477283BPackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "b"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.eclipse.org/ocl/Bug477283b"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "b"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + Bug477283BPackage eINSTANCE = bug477283.b.impl.Bug477283BPackageImpl.init(); + + /** + * The meta object id for the '{@link bug477283.b.impl.BImpl <em>B</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.b.impl.BImpl + * @see bug477283.b.impl.Bug477283BPackageImpl#getB() + * @generated + */ + int B = 0; + + /** + * The feature id for the '<em><b>Ref</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int B__REF = 0; + + /** + * The number of structural features of the '<em>B</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int B_FEATURE_COUNT = 1; + + /** + * The number of operations of the '<em>B</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int B_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link bug477283.b.B <em>B</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>B</em>'. + * @see bug477283.b.B + * @generated + */ + EClass getB(); + + /** + * Returns the meta object for the reference '{@link bug477283.b.B#getRef <em>Ref</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Ref</em>'. + * @see bug477283.b.B#getRef() + * @see #getB() + * @generated + */ + EReference getB_Ref(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + Bug477283BFactory getBug477283BFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link bug477283.b.impl.BImpl <em>B</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see bug477283.b.impl.BImpl + * @see bug477283.b.impl.Bug477283BPackageImpl#getB() + * @generated + */ + EClass B = eINSTANCE.getB(); + + /** + * The meta object literal for the '<em><b>Ref</b></em>' reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference B__REF = eINSTANCE.getB_Ref(); + + } + +} //Bug477283BPackage diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/BImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/BImpl.java new file mode 100644 index 0000000000..65118d54dd --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/BImpl.java @@ -0,0 +1,158 @@ +/** + */ +package bug477283.b.impl; + +import bug477283.a.asub.ASub; + +import bug477283.b.B; +import bug477283.b.Bug477283BPackage; + +import org.eclipse.emf.common.notify.Notification; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>B</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * </p> + * <ul> + * <li>{@link bug477283.b.impl.BImpl#getRef <em>Ref</em>}</li> + * </ul> + * + * @generated + */ +public class BImpl extends MinimalEObjectImpl.Container implements B { + /** + * The cached value of the '{@link #getRef() <em>Ref</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getRef() + * @generated + * @ordered + */ + protected ASub ref; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected BImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return Bug477283BPackage.Literals.B; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ASub getRef() { + if (ref != null && ref.eIsProxy()) { + InternalEObject oldRef = (InternalEObject)ref; + ref = (ASub)eResolveProxy(oldRef); + if (ref != oldRef) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, Bug477283BPackage.B__REF, oldRef, ref)); + } + } + return ref; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ASub basicGetRef() { + return ref; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setRef(ASub newRef) { + ASub oldRef = ref; + ref = newRef; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, Bug477283BPackage.B__REF, oldRef, ref)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case Bug477283BPackage.B__REF: + if (resolve) return getRef(); + return basicGetRef(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case Bug477283BPackage.B__REF: + setRef((ASub)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case Bug477283BPackage.B__REF: + setRef((ASub)null); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case Bug477283BPackage.B__REF: + return ref != null; + } + return super.eIsSet(featureID); + } + +} //BImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/Bug477283BFactoryImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/Bug477283BFactoryImpl.java new file mode 100644 index 0000000000..cdad595749 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/Bug477283BFactoryImpl.java @@ -0,0 +1,95 @@ +/** + */ +package bug477283.b.impl; + +import bug477283.b.*; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283BFactoryImpl extends EFactoryImpl implements Bug477283BFactory { + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static Bug477283BFactory init() { + try { + Bug477283BFactory theBug477283BFactory = (Bug477283BFactory)EPackage.Registry.INSTANCE.getEFactory(Bug477283BPackage.eNS_URI); + if (theBug477283BFactory != null) { + return theBug477283BFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new Bug477283BFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283BFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case Bug477283BPackage.B: return createB(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public B createB() { + BImpl b = new BImpl(); + return b; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283BPackage getBug477283BPackage() { + return (Bug477283BPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static Bug477283BPackage getPackage() { + return Bug477283BPackage.eINSTANCE; + } + +} //Bug477283BFactoryImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/Bug477283BPackageImpl.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/Bug477283BPackageImpl.java new file mode 100644 index 0000000000..f897ccbf2f --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/impl/Bug477283BPackageImpl.java @@ -0,0 +1,186 @@ +/** + */ +package bug477283.b.impl; + +import bug477283.a.Bug477283APackage; + +import bug477283.a.asub.Bug477283subPackage; + +import bug477283.b.Bug477283BFactory; +import bug477283.b.Bug477283BPackage; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class Bug477283BPackageImpl extends EPackageImpl implements Bug477283BPackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass bEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see bug477283.b.Bug477283BPackage#eNS_URI + * @see #init() + * @generated + */ + private Bug477283BPackageImpl() { + super(eNS_URI, Bug477283BFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link Bug477283BPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static Bug477283BPackage init() { + if (isInited) return (Bug477283BPackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283BPackage.eNS_URI); + + // Obtain or create and register package + Bug477283BPackageImpl theBug477283BPackage = (Bug477283BPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof Bug477283BPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new Bug477283BPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + Bug477283APackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theBug477283BPackage.createPackageContents(); + + // Initialize created meta-data + theBug477283BPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBug477283BPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(Bug477283BPackage.eNS_URI, theBug477283BPackage); + return theBug477283BPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getB() { + return bEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getB_Ref() { + return (EReference)bEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283BFactory getBug477283BFactory() { + return (Bug477283BFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + bEClass = createEClass(B); + createEReference(bEClass, B__REF); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + Bug477283subPackage theBug477283subPackage = (Bug477283subPackage)EPackage.Registry.INSTANCE.getEPackage(Bug477283subPackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(bEClass, bug477283.b.B.class, "B", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getB_Ref(), theBug477283subPackage.getASub(), null, "ref", null, 0, 1, bug477283.b.B.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //Bug477283BPackageImpl diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/util/Bug477283BAdapterFactory.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/util/Bug477283BAdapterFactory.java new file mode 100644 index 0000000000..4df8a88088 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/util/Bug477283BAdapterFactory.java @@ -0,0 +1,120 @@ +/** + */ +package bug477283.b.util; + +import bug477283.b.*; + +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; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see bug477283.b.Bug477283BPackage + * @generated + */ +public class Bug477283BAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283BPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283BAdapterFactory() { + if (modelPackage == null) { + modelPackage = Bug477283BPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @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 <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected Bug477283BSwitch<Adapter> modelSwitch = + new Bug477283BSwitch<Adapter>() { + @Override + public Adapter caseB(B object) { + return createBAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link bug477283.b.B <em>B</em>}'. + * <!-- begin-user-doc --> + * 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. + * <!-- end-user-doc --> + * @return the new adapter. + * @see bug477283.b.B + * @generated + */ + public Adapter createBAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //Bug477283BAdapterFactory diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/util/Bug477283BSwitch.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/util/Bug477283BSwitch.java new file mode 100644 index 0000000000..4268814284 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/bug477283/b/util/Bug477283BSwitch.java @@ -0,0 +1,110 @@ +/** + */ +package bug477283.b.util; + +import bug477283.b.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> 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. + * <!-- end-user-doc --> + * @see bug477283.b.Bug477283BPackage + * @generated + */ +public class Bug477283BSwitch<T> extends Switch<T> { + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static Bug477283BPackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Bug477283BSwitch() { + if (modelPackage == null) { + modelPackage = Bug477283BPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case Bug477283BPackage.B: { + B b = (B)theEObject; + T result = caseB(b); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>B</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>B</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseB(B object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //Bug477283BSwitch diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/ImportTests.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/ImportTests.java index d9d0f79357..6339e026d9 100644 --- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/ImportTests.java +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/ImportTests.java @@ -31,6 +31,9 @@ import org.eclipse.ocl.pivot.utilities.ValueUtil; import org.eclipse.ocl.pivot.values.Bag; import org.eclipse.ocl.pivot.values.Value; +import bug477283.a.Bug477283APackage; +import bug477283.b.Bug477283BPackage; + /** * Tests that load a model and verify that there are no unresolved proxies as a result. */ @@ -486,4 +489,17 @@ public class ImportTests extends XtextTestCase assertNotNull(root.getOwnedImports().get(0)); ocl.dispose(); } + + public void testImport_CompleteOCL_NestedPackage_477283() throws Exception { + Bug477283APackage.eINSTANCE.getClass(); + Bug477283BPackage.eINSTANCE.getClass(); + TestOCL ocl = createOCL(); + String testFile = + "import 'http://www.eclipse.org/ocl/Bug477283b'\n" + + "import 'http://www.eclipse.org/ocl/Bug477283asubsub'\n" + + "context b::B\n" + + "def: x(y : asubsub::ASubSub) : Boolean = true\n"; + doLoadFromString(ocl, "Bug477283.ocl", testFile); + ocl.dispose(); + } } diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283A.ecore b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283A.ecore new file mode 100644 index 0000000000..ea91516293 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283A.ecore @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="a" nsURI="http://www.eclipse.org/ocl/Bug477283a" nsPrefix="a"> + <eClassifiers xsi:type="ecore:EClass" name="A"/> + <eSubpackages name="asub" nsURI="http://www.eclipse.org/ocl/Bug477283asub" nsPrefix="asub"> + <eClassifiers xsi:type="ecore:EClass" name="ASub"/> + <eSubpackages name="asubsub" nsURI="http://www.eclipse.org/ocl/Bug477283asubsub" + nsPrefix="asubsub"> + <eClassifiers xsi:type="ecore:EClass" name="ASubSub"/> + </eSubpackages> + </eSubpackages> +</ecore:EPackage> diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283A.genmodel b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283A.genmodel new file mode 100644 index 0000000000..7d99a03367 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283A.genmodel @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" + modelDirectory="/org.eclipse.ocl.examples.xtext.tests/src" modelPluginID="org.eclipse.ocl.examples.xtext.tests" + modelName="A" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" + importerID="org.eclipse.emf.importer.ecore" bundleManifest="false" complianceLevel="7.0" + copyrightFields="false" operationReflection="true" importOrganizing="true" pluginKey=""> + <foreignModel>Bug477283A.ecore</foreignModel> + <genPackages prefix="Bug477283A" basePackage="bug477283" disposableProviderFactory="true" + ecorePackage="Bug477283A.ecore#/"> + <genClasses ecoreClass="Bug477283A.ecore#//A"/> + <nestedGenPackages prefix="Bug477283sub" disposableProviderFactory="true" ecorePackage="Bug477283A.ecore#//asub"> + <genClasses ecoreClass="Bug477283A.ecore#//asub/ASub"/> + <nestedGenPackages prefix="Bug477283Asubsub" disposableProviderFactory="true" + ecorePackage="Bug477283A.ecore#//asub/asubsub"> + <genClasses ecoreClass="Bug477283A.ecore#//asub/asubsub/ASubSub"/> + </nestedGenPackages> + </nestedGenPackages> + </genPackages> +</genmodel:GenModel> diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283B.ecore b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283B.ecore new file mode 100644 index 0000000000..892b40092b --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283B.ecore @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="b" nsURI="http://www.eclipse.org/ocl/Bug477283b" nsPrefix="b"> + <eClassifiers xsi:type="ecore:EClass" name="B"> + <eStructuralFeatures xsi:type="ecore:EReference" name="ref" eType="ecore:EClass Bug477283A.ecore#//asub/ASub"/> + </eClassifiers> +</ecore:EPackage> diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283B.genmodel b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283B.genmodel new file mode 100644 index 0000000000..2111191ce7 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/models/Bug477283B.genmodel @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.ocl.examples.xtext.tests/src" modelPluginID="org.eclipse.ocl.examples.xtext.tests" + modelName="B" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" + importerID="org.eclipse.emf.importer.ecore" bundleManifest="false" complianceLevel="7.0" + copyrightFields="false" usedGenPackages="Bug477283A.genmodel#//a" operationReflection="true" + importOrganizing="true" pluginKey=""> + <foreignModel>Bug477283B.ecore</foreignModel> + <genPackages prefix="Bug477283B" basePackage="bug477283" disposableProviderFactory="true" + ecorePackage="Bug477283B.ecore#/"> + <genClasses ecoreClass="Bug477283B.ecore#//B"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Bug477283B.ecore#//B/ref"/> + </genClasses> + </genPackages> +</genmodel:GenModel> |