eclipse plugin: Implement a convenience method that...

...returns the cardinality of a WMLExpression as Integer
This commit is contained in:
Timotei Dolean 2011-08-04 19:15:58 +00:00
parent 7279390066
commit d887324924
7 changed files with 56 additions and 0 deletions

View file

@ -110,6 +110,11 @@
<details key="body" value="return _Cardinality == '*';"/>
</eAnnotations>
</eOperations>
<eOperations name="getAllowedCount" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="switch( _Cardinality ) {&#xA; case '-': return 0;&#xA; case '?': case '1': return 1;&#xA; }&#xA; // by default let it be infinite times&#xA; return Integer.MAX_VALUE;"/>
</eAnnotations>
</eOperations>
<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 );"/>

View file

@ -57,6 +57,7 @@
<genOperations ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/is_Forbidden"/>
<genOperations ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/is_Optional"/>
<genOperations ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/is_Repeatable"/>
<genOperations ecoreOperation="platform:/resource/org.wesnoth/src-gen/org/wesnoth/WML.ecore#//WMLExpression/getAllowedCount"/>
<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"/>

View file

@ -112,6 +112,15 @@ public interface WMLExpression extends WMLValuedExpression
*/
boolean is_Repeatable();
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model kind="operation"
* annotation="http://www.eclipse.org/emf/2002/GenModel body='switch( _Cardinality ) {\n case \'-\': return 0;\n case \'?\': case \'1\': return 1;\n }\n // by default let it be infinite times\n return Integer.MAX_VALUE;'"
* @generated
*/
int getAllowedCount();
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->

View file

@ -187,6 +187,21 @@ public class WMLExpressionImpl extends WMLValuedExpressionImpl implements WMLExp
return _Cardinality == '*';
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getAllowedCount()
{
switch( _Cardinality ) {
case '-': return 0;
case '?': case '1': return 1;
}
// by default let it be infinite times
return Integer.MAX_VALUE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->

View file

@ -313,6 +313,21 @@ public class WMLMacroCallImpl extends WMLKeyValueImpl implements WMLMacroCall
return _Cardinality == '*';
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getAllowedCount()
{
switch( _Cardinality ) {
case '-': return 0;
case '?': case '1': return 1;
}
// by default let it be infinite times
return Integer.MAX_VALUE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->

View file

@ -908,6 +908,8 @@ public class WmlPackageImpl extends EPackageImpl implements WmlPackage
addEOperation(wmlExpressionEClass, ecorePackage.getEBoolean(), "is_Repeatable", 0, 1, IS_UNIQUE, IS_ORDERED);
addEOperation(wmlExpressionEClass, ecorePackage.getEInt(), "getAllowedCount", 0, 1, IS_UNIQUE, IS_ORDERED);
addEOperation(wmlExpressionEClass, ecorePackage.getEBoolean(), "isWMLTag", 0, 1, IS_UNIQUE, IS_ORDERED);
addEOperation(wmlExpressionEClass, this.getWMLTag(), "asWMLTag", 0, 1, IS_UNIQUE, IS_ORDERED);

View file

@ -22,6 +22,14 @@ process( EClass this ):
createCardinalityOperation( "is_Optional", '?' ) ->
createCardinalityOperation( "is_Repeatable", '*' ) ->
createOperation( "getAllowedCount",
"switch( _Cardinality ) {
case '-': return 0;
case '?': case '1': return 1;
}
// by default let it be infinite times
return Integer.MAX_VALUE;", eint() ) ->
createOperation( "isWMLTag",
"return ( this instanceof WMLTag );", eboolean() ) ->
createOperation( "asWMLTag",
@ -124,6 +132,7 @@ create EClass ESerializable() :
EDataType estring(): ecoreType( "EString" );
EDataType echar(): ecoreType( "EChar" );
EDataType eboolean(): ecoreType( "EBoolean" );
EDataType eint(): ecoreType( "EInt" );
EClass wmlClass( String name ):
wmlPackage().getEClassifier( name );