eclipse plugin: Add convenience methods...
...in the generated grammar classes for converting the WMLExpression to WMLTag/Key
This commit is contained in:
parent
840922fcee
commit
14f2e6a649
7 changed files with 179 additions and 14 deletions
|
@ -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"
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -80,4 +80,38 @@ public interface WMLExpression extends WMLValuedExpression
|
|||
*/
|
||||
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
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.eclipse.emf.ecore.EClass;
|
|||
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;
|
||||
|
||||
/**
|
||||
|
@ -138,6 +140,46 @@ public class WMLExpressionImpl extends WMLValuedExpressionImpl implements WMLExp
|
|||
eNotify(new ENotificationImpl(this, Notification.SET, WmlPackage.WML_EXPRESSION__CARDINALITY, old_Cardinality, _Cardinality));
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- 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 -->
|
||||
|
|
|
@ -22,9 +22,11 @@ import org.eclipse.emf.ecore.util.EObjectContainmentEList;
|
|||
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;
|
||||
|
||||
|
@ -264,6 +266,46 @@ public class WMLMacroCallImpl extends WMLKeyValueImpl implements WMLMacroCall
|
|||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- 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 -->
|
||||
|
|
|
@ -770,6 +770,14 @@ public class WmlPackageImpl extends EPackageImpl implements WmlPackage
|
|||
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);
|
||||
|
|
|
@ -14,9 +14,13 @@ process( EClass this ):
|
|||
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 @@ process( EAttribute this ):
|
|||
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();
|
Loading…
Add table
Reference in a new issue