| author | mclay | 2008-10-30 17:37:04 (EDT) |
|---|---|---|
| committer | sefftinge | 2008-10-30 17:37:04 (EDT) |
| commit | a6bcc329dd325afff771f7d00009f0e08316cf73 (patch) (side-by-side diff) | |
| tree | 8679c36486383239c47ded896f72e2f5affb22f0 | |
| parent | ba3d730c10ca8be2a06d969a42796d436eefece4 (diff) | |
| download | org.eclipse.xtext-a6bcc329dd325afff771f7d00009f0e08316cf73.zip org.eclipse.xtext-a6bcc329dd325afff771f7d00009f0e08316cf73.tar.gz org.eclipse.xtext-a6bcc329dd325afff771f7d00009f0e08316cf73.tar.bz2 | |
add: a java based model of an imported ecore to test callback of 'typed' completion proposal methods
11 files changed, 970 insertions, 0 deletions
diff --git a/devtools/org.eclipse.xtext.reference/META-INF/MANIFEST.MF b/devtools/org.eclipse.xtext.reference/META-INF/MANIFEST.MF index 74e8be1..630ba7e 100644 --- a/devtools/org.eclipse.xtext.reference/META-INF/MANIFEST.MF +++ b/devtools/org.eclipse.xtext.reference/META-INF/MANIFEST.MF @@ -6,6 +6,7 @@ Bundle-Version: 0.7.0.qualifier Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Vendor: itemis AG Export-Package: org.eclipse.xtext.reference, + ReferenceModel, org.eclipse.xtext.reference.parser, org.eclipse.xtext.reference.parser.internal, org.eclipse.xtext.reference.parsetree.reconstr, diff --git a/devtools/org.eclipse.xtext.reference/plugin.xml b/devtools/org.eclipse.xtext.reference/plugin.xml index c961779..7542674 100644 --- a/devtools/org.eclipse.xtext.reference/plugin.xml +++ b/devtools/org.eclipse.xtext.reference/plugin.xml @@ -1,4 +1,11 @@ <plugin> + <extension + point="org.eclipse.emf.ecore.generated_package"> + <package + uri="classpath:/org/eclipse/xtext/reference/ReferenceModel.ecore" + class="ReferenceModel.ReferenceModelPackage"> + </package> + </extension> <extension point="org.eclipse.xtend.typesystem.emf.checks"> diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/CustomType.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/CustomType.java new file mode 100644 index 0000000..fc32e82 --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/CustomType.java @@ -0,0 +1,54 @@ +/** + * <copyright> + * </copyright> + * + * $Id: CustomType.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Custom Type</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link ReferenceModel.CustomType#getName <em>Name</em>}</li> + * </ul> + * </p> + * + * @see ReferenceModel.ReferenceModelPackage#getCustomType() + * @model + * @generated + */ +public interface CustomType extends EObject { + /** + * Returns the value of the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Name</em>' attribute. + * @see #setName(String) + * @see ReferenceModel.ReferenceModelPackage#getCustomType_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link ReferenceModel.CustomType#getName <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Name</em>' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + +} // CustomType diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/ReferenceModelFactory.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/ReferenceModelFactory.java new file mode 100644 index 0000000..c60846e --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/ReferenceModelFactory.java @@ -0,0 +1,46 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceModelFactory.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel; + +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 ReferenceModel.ReferenceModelPackage + * @generated + */ +public interface ReferenceModelFactory extends EFactory { + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + ReferenceModelFactory eINSTANCE = ReferenceModel.impl.ReferenceModelFactoryImpl.init(); + + /** + * Returns a new object of class '<em>Custom Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Custom Type</em>'. + * @generated + */ + CustomType createCustomType(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + ReferenceModelPackage getReferenceModelPackage(); + +} //ReferenceModelFactory diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/ReferenceModelPackage.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/ReferenceModelPackage.java new file mode 100644 index 0000000..0f11a04 --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/ReferenceModelPackage.java @@ -0,0 +1,153 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceModelPackage.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel; + +import org.eclipse.emf.ecore.EAttribute; +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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see ReferenceModel.ReferenceModelFactory + * @model kind="package" + * @generated + */ +public interface ReferenceModelPackage extends EPackage { + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "ReferenceModel"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://eclipse.org/xtext/reference/ReferenceModel"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "ReferenceModel"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + ReferenceModelPackage eINSTANCE = ReferenceModel.impl.ReferenceModelPackageImpl.init(); + + /** + * The meta object id for the '{@link ReferenceModel.impl.CustomTypeImpl <em>Custom Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see ReferenceModel.impl.CustomTypeImpl + * @see ReferenceModel.impl.ReferenceModelPackageImpl#getCustomType() + * @generated + */ + int CUSTOM_TYPE = 0; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CUSTOM_TYPE__NAME = 0; + + /** + * The number of structural features of the '<em>Custom Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CUSTOM_TYPE_FEATURE_COUNT = 1; + + + /** + * Returns the meta object for class '{@link ReferenceModel.CustomType <em>Custom Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Custom Type</em>'. + * @see ReferenceModel.CustomType + * @generated + */ + EClass getCustomType(); + + /** + * Returns the meta object for the attribute '{@link ReferenceModel.CustomType#getName <em>Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Name</em>'. + * @see ReferenceModel.CustomType#getName() + * @see #getCustomType() + * @generated + */ + EAttribute getCustomType_Name(); + + /** + * 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 + */ + ReferenceModelFactory getReferenceModelFactory(); + + /** + * <!-- 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 enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link ReferenceModel.impl.CustomTypeImpl <em>Custom Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see ReferenceModel.impl.CustomTypeImpl + * @see ReferenceModel.impl.ReferenceModelPackageImpl#getCustomType() + * @generated + */ + EClass CUSTOM_TYPE = eINSTANCE.getCustomType(); + + /** + * The meta object literal for the '<em><b>Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute CUSTOM_TYPE__NAME = eINSTANCE.getCustomType_Name(); + + } + +} //ReferenceModelPackage diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/CustomTypeImpl.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/CustomTypeImpl.java new file mode 100644 index 0000000..7290a5c --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/CustomTypeImpl.java @@ -0,0 +1,167 @@ +/** + * <copyright> + * </copyright> + * + * $Id: CustomTypeImpl.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel.impl; + +import ReferenceModel.CustomType; +import ReferenceModel.ReferenceModelPackage; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Custom Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link ReferenceModel.impl.CustomTypeImpl#getName <em>Name</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class CustomTypeImpl extends EObjectImpl implements CustomType { + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected CustomTypeImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return ReferenceModelPackage.Literals.CUSTOM_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ReferenceModelPackage.CUSTOM_TYPE__NAME, oldName, name)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ReferenceModelPackage.CUSTOM_TYPE__NAME: + return getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ReferenceModelPackage.CUSTOM_TYPE__NAME: + setName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ReferenceModelPackage.CUSTOM_TYPE__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ReferenceModelPackage.CUSTOM_TYPE__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //CustomTypeImpl diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/ReferenceModelFactoryImpl.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/ReferenceModelFactoryImpl.java new file mode 100644 index 0000000..95f3b21 --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/ReferenceModelFactoryImpl.java @@ -0,0 +1,99 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceModelFactoryImpl.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel.impl; + +import ReferenceModel.*; + +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 ReferenceModelFactoryImpl extends EFactoryImpl implements ReferenceModelFactory { + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static ReferenceModelFactory init() { + try { + ReferenceModelFactory theReferenceModelFactory = (ReferenceModelFactory)EPackage.Registry.INSTANCE.getEFactory("http://eclipse.org/xtext/reference/ReferenceModel"); + if (theReferenceModelFactory != null) { + return theReferenceModelFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new ReferenceModelFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ReferenceModelFactoryImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case ReferenceModelPackage.CUSTOM_TYPE: return createCustomType(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public CustomType createCustomType() { + CustomTypeImpl customType = new CustomTypeImpl(); + return customType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ReferenceModelPackage getReferenceModelPackage() { + return (ReferenceModelPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static ReferenceModelPackage getPackage() { + return ReferenceModelPackage.eINSTANCE; + } + +} //ReferenceModelFactoryImpl diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/ReferenceModelPackageImpl.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/ReferenceModelPackageImpl.java new file mode 100644 index 0000000..a2b38bb --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/impl/ReferenceModelPackageImpl.java @@ -0,0 +1,188 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceModelPackageImpl.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel.impl; + +import ReferenceModel.CustomType; +import ReferenceModel.ReferenceModelFactory; +import ReferenceModel.ReferenceModelPackage; + +import org.eclipse.emf.ecore.EAttribute; +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 ReferenceModelPackageImpl extends EPackageImpl implements ReferenceModelPackage { + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass customTypeEClass = 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 ReferenceModel.ReferenceModelPackage#eNS_URI + * @see #init() + * @generated + */ + private ReferenceModelPackageImpl() { + super(eNS_URI, ReferenceModelFactory.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. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ReferenceModelPackage init() { + if (isInited) return (ReferenceModelPackage)EPackage.Registry.INSTANCE.getEPackage(ReferenceModelPackage.eNS_URI); + + // Obtain or create and register package + ReferenceModelPackageImpl theReferenceModelPackage = (ReferenceModelPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof ReferenceModelPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new ReferenceModelPackageImpl()); + + isInited = true; + + // Create package meta-data objects + theReferenceModelPackage.createPackageContents(); + + // Initialize created meta-data + theReferenceModelPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theReferenceModelPackage.freeze(); + + return theReferenceModelPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getCustomType() { + return customTypeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getCustomType_Name() { + return (EAttribute)customTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ReferenceModelFactory getReferenceModelFactory() { + return (ReferenceModelFactory)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 + customTypeEClass = createEClass(CUSTOM_TYPE); + createEAttribute(customTypeEClass, CUSTOM_TYPE__NAME); + } + + /** + * <!-- 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 and features; add operations and parameters + initEClass(customTypeEClass, CustomType.class, "CustomType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getCustomType_Name(), ecorePackage.getEString(), "name", null, 0, 1, CustomType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //ReferenceModelPackageImpl diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/util/ReferenceModelAdapterFactory.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/util/ReferenceModelAdapterFactory.java new file mode 100644 index 0000000..714e840 --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/util/ReferenceModelAdapterFactory.java @@ -0,0 +1,124 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceModelAdapterFactory.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel.util; + +import ReferenceModel.*; + +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 ReferenceModel.ReferenceModelPackage + * @generated + */ +public class ReferenceModelAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static ReferenceModelPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ReferenceModelAdapterFactory() { + if (modelPackage == null) { + modelPackage = ReferenceModelPackage.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 ReferenceModelSwitch<Adapter> modelSwitch = + new ReferenceModelSwitch<Adapter>() { + @Override + public Adapter caseCustomType(CustomType object) { + return createCustomTypeAdapter(); + } + @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 ReferenceModel.CustomType <em>Custom Type</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 ReferenceModel.CustomType + * @generated + */ + public Adapter createCustomTypeAdapter() { + 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; + } + +} //ReferenceModelAdapterFactory diff --git a/devtools/org.eclipse.xtext.reference/src/ReferenceModel/util/ReferenceModelSwitch.java b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/util/ReferenceModelSwitch.java new file mode 100644 index 0000000..93e9812 --- a/dev/null +++ b/devtools/org.eclipse.xtext.reference/src/ReferenceModel/util/ReferenceModelSwitch.java @@ -0,0 +1,130 @@ +/** + * <copyright> + * </copyright> + * + * $Id: ReferenceModelSwitch.java,v 1.1 2008/10/30 21:37:04 mclay Exp $ + */ +package ReferenceModel.util; + +import ReferenceModel.*; + +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- 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 ReferenceModel.ReferenceModelPackage + * @generated + */ +public class ReferenceModelSwitch<T> { + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static ReferenceModelPackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ReferenceModelSwitch() { + if (modelPackage == null) { + modelPackage = ReferenceModelPackage.eINSTANCE; + } + } + + /** + * 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 + */ + public T doSwitch(EObject theEObject) { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * 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 + */ + protected T doSwitch(EClass theEClass, EObject theEObject) { + if (theEClass.eContainer() == modelPackage) { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return + eSuperTypes.isEmpty() ? + defaultCase(theEObject) : + doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * 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 + */ + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case ReferenceModelPackage.CUSTOM_TYPE: { + CustomType customType = (CustomType)theEObject; + T result = caseCustomType(customType); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Custom Type</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>Custom Type</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseCustomType(CustomType 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 + */ + public T defaultCase(EObject object) { + return null; + } + +} //ReferenceModelSwitch diff --git a/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.xtext b/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.xtext index 7cc83e3..3777ac6 100644 --- a/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.xtext +++ b/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.xtext @@ -8,6 +8,7 @@ *******************************************************************************/ language org.eclipse.xtext.reference.ReferenceGrammar generate ReferenceGrammar "http://eclipse.org/xtext/reference/ReferenceGrammar" +import "classpath:/org/eclipse/xtext/reference/ReferenceModel.ecore" as ReferenceModel Spielplatz : ( "spielplatz" groesse = INT ( beschreibung = STRING ) ? "{" |

