Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Duplicate field in generated Package
[SOLVED] Duplicate field in generated Package [message #1660816] Mon, 09 March 2015 10:52 Go to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
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 Go to previous message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
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
;
Previous Topic:XtextCON 2015
Next Topic:accelerate the MWE2 workflow generation
Goto Forum:
  


Current Time: Mon Apr 19 12:37:33 GMT 2021

Powered by FUDForum. Page generated in 0.01274 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top