Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to create a Boolean rule with true as default value
How to create a Boolean rule with true as default value [message #1780823] Sun, 28 January 2018 22:25 Go to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Hi guys.
How could I get a true value as default value with a boolean rule like:
BOOLEAN returns ecore::EBoolean: 'true' | 'false';

Is there a way to get a true value as default in a boolean rule?

Best regards,
Márcio.
Re: How to create a Boolean rule with true as default value [message #1780833 is a reply to message #1780823] Mon, 29 January 2018 05:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi do you mean for that rule or for a optional feature using that rule?
Have a look at IXtext2EcorePostprocessor
Unfortunately support isn't that good anymore in recent Xtext versions
https://bugs.eclipse.org/bugs/show_bug.cgi?id=483209


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to create a Boolean rule with true as default value [message #1780846 is a reply to message #1780833] Mon, 29 January 2018 08:15 Go to previous messageGo to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Thanks for your replay.
Well, I think using an enum is not a real boolean, but works:
enum BOOLEAN_2: 
	TRUE='true' | FALSE='false'
;
Re: How to create a Boolean rule with true as default value [message #1780858 is a reply to message #1780846] Mon, 29 January 2018 10:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Xtext is a good tool for exploiting grammars to produce parsers and editors. For many simple use cases Xtext is also able to autogenerate an underlying Ecore model for the parsed content. However Xtext is not a replacement for proper Ecore tooling and so if you need more precise/predictable control of the Ecore file you would be well advised to treat the Ecore file as a manual input contribution rather than struggle to trick Xtext into autogenerating it as an intermediate.

Regards

Ed Willink

Re: How to create a Boolean rule with true as default value [message #1780871 is a reply to message #1780858] Mon, 29 January 2018 12:26 Go to previous messageGo to next message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Ok I understand. I'm a little new in xText yet. I think xText is great.
So, you could point to a good documentation reference about this issue? Or some examples?

Regards,
Márcio.
Re: How to create a Boolean rule with true as default value [message #1780874 is a reply to message #1780871] Mon, 29 January 2018 13:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Example: In http://git.eclipse.org/c/mmt/org.eclipse.qvtd.git/tree/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/QVTrelation.xtext you can see that all models are imported.

Transitioning from an autogenerated model file to a manually-generated imported model file is a little tricky because a simple migration of the autogenerated files to a conventional "model" folder doesn't quite work; you have to fix up references. I raised a Bugzilla [1] suggesting a migration tool, but it remains as an enhancement request. There are clues as to what to change. Easy for an EMF user who already understands GenModel error messages; a bit daunting for a newbie.

Once you have a manually generated model, both grammar and model must be evolved compatibly. Xtext is now quite good about telling you what is wrong with your model, but it is an area where there are new idiomatic errors to learn.

You may prefer to live with default Xtext models until you have more or less finalized your grammar and then migrate to manual generation as a 'production' polishing step.

Regards

Ed Willink

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=340028

Re: How to create a Boolean rule with true as default value [message #1781182 is a reply to message #1780874] Fri, 02 February 2018 10:39 Go to previous message
Márcio Koch is currently offline Márcio KochFriend
Messages: 57
Registered: August 2013
Member
Hum, I understood. I have another XText project that generates contracts for our micro-services, wich I think is manually-generated, because each rule in the grammar has a correspondent class in a .xcore file wich is imported by its "model" folder path into the xtext file. This other Xtext project was developed by an experient external xText developer that go out. So I can use this other project as a learning model.

Thank you very much for your help.
Previous Topic:Xbase DSL run codegen with Maven
Next Topic:[SOLVED] Confirming new renaming infracture is not for Xbase languages
Goto Forum:
  


Current Time: Sat Apr 20 03:50:02 GMT 2024

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

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

Back to the top