Author: timotei
Date: Tue Jul 26 17:34:57 2011
New Revision: 50437

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50437&view=rev
Log:
eclipse plugin: Add convenience methods in the
generated grammar classes for converting
the WMLExpression to WMLTag/Key

Modified:
    trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.ecore
    trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.genmodel
    trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/WMLExpression.java
    
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLExpressionImpl.java
    
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLMacroCallImpl.java
    
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WmlPackageImpl.java
    trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/WMLPostProcessor.ext

Modified: trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.ecore
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.ecore?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.ecore (original)
+++ trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.ecore Tue Jul 26 
17:34:57 2011
@@ -92,6 +92,26 @@
   </eClassifiers>
   <eClassifiers xsi:type="ecore:EClass" name="WMLRootExpression" 
eSuperTypes="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression"/>
   <eClassifiers xsi:type="ecore:EClass" name="WMLExpression" 
eSuperTypes="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLValuedExpression">
+    <eOperations name="isWMLTag" eType="ecore:EDataType 
http://www.eclipse.org/emf/2002/Ecore#//EBoolean";>
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel";>
+        <details key="body" value="return ( this instanceof WMLTag );"/>
+      </eAnnotations>
+    </eOperations>
+    <eOperations name="asWMLTag" eType="ecore:EClass 
platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLTag">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel";>
+        <details key="body" value="if ( !( this instanceof WMLTag ) ) return 
null; return ( WMLTag ) this;"/>
+      </eAnnotations>
+    </eOperations>
+    <eOperations name="isWMLKey" eType="ecore:EDataType 
http://www.eclipse.org/emf/2002/Ecore#//EBoolean";>
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel";>
+        <details key="body" value="return ( this instanceof WMLKey );"/>
+      </eAnnotations>
+    </eOperations>
+    <eOperations name="asWMLKey" eType="ecore:EClass 
platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLKey">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel";>
+        <details key="body" value="if ( !( this instanceof WMLKey ) ) return 
null; return ( WMLKey ) this;"/>
+      </eAnnotations>
+    </eOperations>
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" 
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString";
         defaultValueLiteral=""/>
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="_Cardinality" 
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EChar";

Modified: trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.genmodel
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.genmodel?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.genmodel (original)
+++ trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/WML.genmodel Tue Jul 26 
17:34:57 2011
@@ -54,6 +54,10 @@
     <genClasses 
ecoreClass="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression">
       <genFeatures createChild="false" ecoreFeature="ecore:EAttribute 
platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/name"/>
       <genFeatures createChild="false" ecoreFeature="ecore:EAttribute 
platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/_Cardinality"/>
+      <genOperations 
ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/isWMLTag"/>
+      <genOperations 
ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/asWMLTag"/>
+      <genOperations 
ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/isWMLKey"/>
+      <genOperations 
ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/asWMLKey"/>
     </genClasses>
     <genClasses 
ecoreClass="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLValuedExpression"/>
     <genClasses 
ecoreClass="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLTextdomain"/>

Modified: 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/WMLExpression.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/WMLExpression.java?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/WMLExpression.java 
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/WMLExpression.java 
Tue Jul 26 17:34:57 2011
@@ -80,4 +80,38 @@
    */
   void set_Cardinality(char value);
 
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model kind="operation"
+   *        annotation="http://www.eclipse.org/emf/2002/GenModel body='return 
( this instanceof WMLTag );'"
+   * @generated
+   */
+  boolean isWMLTag();
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model annotation="http://www.eclipse.org/emf/2002/GenModel body='if ( !( 
this instanceof WMLTag ) ) return null; return ( WMLTag ) this;'"
+   * @generated
+   */
+  WMLTag asWMLTag();
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model kind="operation"
+   *        annotation="http://www.eclipse.org/emf/2002/GenModel body='return 
( this instanceof WMLKey );'"
+   * @generated
+   */
+  boolean isWMLKey();
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @model annotation="http://www.eclipse.org/emf/2002/GenModel body='if ( !( 
this instanceof WMLKey ) ) return null; return ( WMLKey ) this;'"
+   * @generated
+   */
+  WMLKey asWMLKey();
+
 } // WMLExpression

Modified: 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLExpressionImpl.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLExpressionImpl.java?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLExpressionImpl.java
 (original)
+++ 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLExpressionImpl.java
 Tue Jul 26 17:34:57 2011
@@ -13,6 +13,8 @@
 import org.eclipse.emf.ecore.impl.ENotificationImpl;
 
 import org.wesnoth.wml.WMLExpression;
+import org.wesnoth.wml.WMLKey;
+import org.wesnoth.wml.WMLTag;
 import org.wesnoth.wml.WmlPackage;
 
 /**
@@ -143,6 +145,46 @@
    * <!-- end-user-doc -->
    * @generated
    */
+  public boolean isWMLTag()
+  {
+    return ( this instanceof WMLTag );
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public WMLTag asWMLTag()
+  {
+    if ( !( this instanceof WMLTag ) ) return null; return ( WMLTag ) this;
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public boolean isWMLKey()
+  {
+    return ( this instanceof WMLKey );
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public WMLKey asWMLKey()
+  {
+    if ( !( this instanceof WMLKey ) ) return null; return ( WMLKey ) this;
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
   @Override
   public Object eGet(int featureID, boolean resolve, boolean coreType)
   {

Modified: 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLMacroCallImpl.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLMacroCallImpl.java?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLMacroCallImpl.java
 (original)
+++ 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WMLMacroCallImpl.java
 Tue Jul 26 17:34:57 2011
@@ -22,9 +22,11 @@
 import org.eclipse.emf.ecore.util.InternalEList;
 
 import org.wesnoth.wml.WMLExpression;
+import org.wesnoth.wml.WMLKey;
 import org.wesnoth.wml.WMLMacroCall;
 import org.wesnoth.wml.WMLMacroCallParameter;
 import org.wesnoth.wml.WMLRootExpression;
+import org.wesnoth.wml.WMLTag;
 import org.wesnoth.wml.WMLValuedExpression;
 import org.wesnoth.wml.WmlPackage;
 
@@ -269,6 +271,46 @@
    * <!-- end-user-doc -->
    * @generated
    */
+  public boolean isWMLTag()
+  {
+    return ( this instanceof WMLTag );
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public WMLTag asWMLTag()
+  {
+    if ( !( this instanceof WMLTag ) ) return null; return ( WMLTag ) this;
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public boolean isWMLKey()
+  {
+    return ( this instanceof WMLKey );
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  public WMLKey asWMLKey()
+  {
+    if ( !( this instanceof WMLKey ) ) return null; return ( WMLKey ) this;
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
   @Override
   public NotificationChain eInverseRemove(InternalEObject otherEnd, int 
featureID, NotificationChain msgs)
   {

Modified: 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WmlPackageImpl.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WmlPackageImpl.java?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WmlPackageImpl.java
 (original)
+++ 
trunk/utils/umc_dev/org.wesnoth/src-gen/org/wesnoth/wml/impl/WmlPackageImpl.java
 Tue Jul 26 17:34:57 2011
@@ -770,6 +770,14 @@
     initEAttribute(getWMLExpression_Name(), ecorePackage.getEString(), "name", 
"", 0, 1, WMLExpression.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, 
!IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
     initEAttribute(getWMLExpression__Cardinality(), ecorePackage.getEChar(), 
"_Cardinality", " ", 0, 1, WMLExpression.class, !IS_TRANSIENT, !IS_VOLATILE, 
IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
+    addEOperation(wmlExpressionEClass, ecorePackage.getEBoolean(), "isWMLTag", 
0, 1, IS_UNIQUE, IS_ORDERED);
+
+    addEOperation(wmlExpressionEClass, this.getWMLTag(), "asWMLTag", 0, 1, 
IS_UNIQUE, IS_ORDERED);
+
+    addEOperation(wmlExpressionEClass, ecorePackage.getEBoolean(), "isWMLKey", 
0, 1, IS_UNIQUE, IS_ORDERED);
+
+    addEOperation(wmlExpressionEClass, this.getWMLKey(), "asWMLKey", 0, 1, 
IS_UNIQUE, IS_ORDERED);
+
     initEClass(wmlValuedExpressionEClass, WMLValuedExpression.class, 
"WMLValuedExpression", !IS_ABSTRACT, !IS_INTERFACE, 
IS_GENERATED_INSTANCE_CLASS);
 
     initEClass(wmlTextdomainEClass, WMLTextdomain.class, "WMLTextdomain", 
!IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);

Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/WMLPostProcessor.ext
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/WMLPostProcessor.ext?rev=50437&r1=50436&r2=50437&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/WMLPostProcessor.ext 
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/WMLPostProcessor.ext Tue 
Jul 26 17:34:57 2011
@@ -14,9 +14,13 @@
     eStructuralFeatures.process() ->
      
     // enrich the grammar elements with schema-specific attributes
-    if name == "WMLExpression" then
-        createAttribute( "_Cardinality", "EChar", " " )
-    else if name == "WMLTag" then {
+    if name == "WMLExpression" then {
+        createAttribute( "_Cardinality", "EChar", " " ) ->
+        createOperation( "isWMLTag", "return ( this instanceof WMLTag );", 
"EBoolean" ) ->
+        createOperation( "asWMLTag", "if ( !( this instanceof WMLTag ) ) 
return null; return ( WMLTag ) this;", "WMLTag" ) ->
+        createOperation( "isWMLKey", "return ( this instanceof WMLKey );", 
"EBoolean" ) ->
+        createOperation( "asWMLKey", "if ( !( this instanceof WMLKey ) ) 
return null; return ( WMLKey ) this;", "WMLKey" )
+    } else if name == "WMLTag" then {
         createAttribute( "_InhertedTagName", "EString", "" ) ->
         createAttribute( "_NeedingExpansion", "EBoolean", "false" ) ->
         createAttribute( "_Description", "EString", "" )
@@ -40,28 +44,39 @@
         setDefaultValueLiteral( "" );
 
 createCardinalityOperation( EClass this, String name, char chr ) :
-    let op = newCardinalityOperation( name ) : newCardinalityAnnotation( op, 
chr ) ;
+    let op = newOperation( name, "EBoolean" ) : 
+        newAnnotation( op, "return _Cardinality == '" + chr + "';" );
 
-create EOperation this newCardinalityOperation( EClass owner, String name ) :
-    setName( name ) -> setEType( getEcoreDataType( "EBoolean" ) ) ->
+createOperation( EClass this, String name, String body, String returnType):
+    let op = newOperation( name, returnType) : newAnnotation( op, body ); 
+
+create EOperation this newOperation( EClass owner, String name, String 
returnType ) :
+    setName( name ) -> setEType( getDataType( returnType ) ) ->
     owner.eOperations.add( this );
 
-create EAnnotation this newCardinalityAnnotation( EOperation op, char chr ):
+create EAnnotation this newAnnotation( EOperation op, String value ):
     let an = new EStringToStringMapEntry :
         setSource( "http://www.eclipse.org/emf/2002/GenModel"; ) ->
         an.setKey( "body" ) ->
-        an.setValue( "return _Cardinality == '" + chr + "';" ) ->
+        an.setValue( value ) ->
         details.add( an ) ->
         op.eAnnotations.add( this );
 
 create EAttribute this createAttribute( EClass owner, String name, String 
type, String defValue ) :
     setName( name ) -> 
-    setEType( getEcoreDataType( type ) ) ->
+    setEType( getDataType( type ) ) ->
     setDefaultValueLiteral( defValue ) ->
-    
-    // add attribute
+    // add attribute to class
     owner.eStructuralFeatures.add( this );
      
-EDataType getEcoreDataType(String name) :
-    org::eclipse::emf::ecore::EcorePackage::eINSTANCE.getEClassifier(name)
-;
+EDataType getDataType( String name ): 
+    if name.startsWith( "E" ) then
+        ecorePackage().getEClassifier( name )
+    else
+        wmlPackage().getEClassifier( name );
+
+EPackage wmlPackage():
+    JAVA org.wesnoth.wml.impl.WmlPackageImpl.init();
+
+EPackage ecorePackage(): 
+    JAVA org.eclipse.emf.ecore.impl.EcorePackageImpl.init();


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to