[SOLVED] Duplicate field in generated Package [message #1660816] |
Mon, 09 March 2015 10:52 |
|
Dear all,
I have defined a DSL which is extending the Xtend grammar (see the attached SARL.xtext file).
When I generate with MWE2, I obtain duplicate fields in the Java code of SARLPackage:
- int SARL_CONSTRUCTOR_OPERATION__EXCEPTIONS
- int SARL_CONSTRUCTOR_OPERATION__TYPE_PARAMETERS
- int SARL_CONSTRUCTOR_OPERATION__EXPRESSION
- int SARL_CONSTRUCTOR_OPERATION__PARAMETERS
The corresponding Xtext grammar rule is:
SarlConstructor returns xtend::XtendConstructor:
{SarlConstructorOperation}
annotations+=XAnnotation*
{SarlConstructorOperation.annotationInfo = current}
modifiers+=CommonModifier*
'new'
('<' typeParameters+=JvmTypeParameter (',' typeParameters+=JvmTypeParameter)* '>')?
(=> '(' (parameters+=Parameter (',' parameters+=Parameter)*)?
')'
)?
('throws' exceptions+=JvmTypeReference (',' exceptions+=JvmTypeReference)*)?
expression=XBlockExpression
;
The grammar rule SarlConstructor is the only one rule which is producing the duplicate field error.
What was wrong in my grammar?
Yours.
Stéphane.
[Updated on: Mon, 20 April 2015 08:47] Report message to a moderator
|
|
|
Re: Duplicate field in generated Package [message #1660862 is a reply to message #1660816] |
Mon, 09 March 2015 11:19 |
|
I found a work around that I not sure it is solving the background problem, but give a solution in in my specific case: since my SARLConstructorOperation does not add any information, it could be safely replaced by the super type XtendConstructor:
SarlConstructor returns xtend::XtendConstructor:
{xtend::XtendConstructor}
annotations+=XAnnotation*
{xtend::XtendConstructor.annotationInfo = current}
modifiers+=CommonModifier*
'new'
('<' typeParameters+=JvmTypeParameter (',' typeParameters+=JvmTypeParameter)* '>')?
(=> '(' (parameters+=Parameter (',' parameters+=Parameter)*)?
')'
)?
('throws' exceptions+=JvmTypeReference (',' exceptions+=JvmTypeReference)*)?
expression=XBlockExpression
;
|
|
|
Powered by
FUDForum. Page generated in 0.03808 seconds