Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How could I create a new Xtext project from existing ecore model then there is no brackets in xtext?(How could I create a new Xtext project from existing ecore model then there is no brackets in xtext?)
How could I create a new Xtext project from existing ecore model then there is no brackets in xtext? [message #1840740] Fri, 23 April 2021 07:30 Go to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Hi, I am trying to create a new xtext project from an existing ecore model, however I found there are a lot of brackets such as '{', '}' in my xtext file, I don't need them, how can I remove them automatically? I mean when I generate a xtext project from an existing ecore, then there is no '{' and '}' in my xtext file.
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840756 is a reply to message #1840740] Fri, 23 April 2021 12:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
there is no customization for the wizard so you would either to remove it yourself manually
or write a patched version of the wizard / Ecore2XtextGenerator


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840757 is a reply to message #1840756] Fri, 23 April 2021 12:45 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Okay, Thank you Christian, so I seem to have to write a generator by my own.
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840760 is a reply to message #1840757] Fri, 23 April 2021 12:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you can simply edit the xtext file

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840762 is a reply to message #1840760] Fri, 23 April 2021 12:57 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Yes, I can edit the xtext file manually, but I still want to know if there is a way for me to remove all the brackets automatically.
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840763 is a reply to message #1840762] Fri, 23 April 2021 12:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i assume a find and replace would do the job.
the more interesting question would be if the grammar is still unambiguous then


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840764 is a reply to message #1840763] Fri, 23 April 2021 13:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The Ecore2Xtext generator is a very helpful starter, but it is only a starter since it cannot know what your aesthetic preferences are for the use of e.g. many keywords/quoted strings/special punctuation and for how to nest constructs. It therefore just takes a relatively simple and reliable approach that gives you something much more user friendly than XML but probably not that much different from HUTN. You need to use your expertise to tailor the grammar to something much more aesthetically pleasing.

Regards

Ed Willink
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840765 is a reply to message #1840763] Fri, 23 April 2021 13:12 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
yes, if the purpose was only to remove all the brackets, then a find and a replace would do the job, but my next job could be for example to move a specific attribute (for example 'shortName') to another place, or some other more complicated intention, in that case, I assume only find and replace won't be enough for me.
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840766 is a reply to message #1840764] Fri, 23 April 2021 13:27 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Okay, Thank you Ed, Thank you for your reply. Could ask you a further question: where could I find Ecore2Xtext generator, is it a plugin that I need download and install?

Best regards,
Weixing
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840767 is a reply to message #1840766] Fri, 23 April 2021 13:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
no class name is org.eclipse.xtext.xtext.wizard.ecore2xtext.Ecore2XtextGrammarCreator
and its part of the org.eclipse.xtext.xtext.wizard plugin
https://github.com/eclipse/xtext-core/tree/master/org.eclipse.xtext.xtext.wizard/src/org/eclipse/xtext/xtext/wizard/ecore2xtext


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 23 April 2021 13:33]

Report message to a moderator

Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840772 is a reply to message #1840767] Fri, 23 April 2021 14:00 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Okay, thank you so much Christian, so I need to install org.eclipse.xtext.xtext.wizard plugin, right?

Best regards,
Weixing
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840775 is a reply to message #1840772] Fri, 23 April 2021 14:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
it is already installed

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840777 is a reply to message #1840775] Fri, 23 April 2021 14:20 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Okay, Thank you Christian, but maybe I am a little fool, I can't find it in my eclipse projects. In my current understanding, I should find the org.eclipse.xtext.xtext.wizard.ecore2xtext.Ecore2XtextGrammarCreator which is part of org.eclipse.xtext.xtext.wizard plugin, then I modify it to achieve my purpose, right?

Best regards,
Weixing
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840784 is a reply to message #1840777] Fri, 23 April 2021 16:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
You need to add it to manifest

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840785 is a reply to message #1840784] Fri, 23 April 2021 16:14 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Okay, got it, thank you so much!!

Best regards,
Weixing
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840791 is a reply to message #1840785] Fri, 23 April 2021 17:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The standard *.genmodel has a variety of Model/Edit sections for each EClassifier/EStructuralFeature. It would be technically possible for the *.genmodel to also have a Grammar section to select and parameterize a parsing/formatting idiom for each EClassifier/EStructuralFeature.

However while the *.genmodel is regularly used to regenerate the model implementation and edit ItemProviders, it is difficult to see any users choosing to treat the *.ecore as the master with the *.xtext a regularly re-auto-generated slave. So with the Ecore2Xtext conversion a one-off throwaway for only a small number of users in the first place,, it is hard to see how anyone will be motivated enough to provide the enhanced wizard.

Regards

Ed Willink
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840792 is a reply to message #1840791] Fri, 23 April 2021 18:19 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Okay, thank you Ed, I see, that's why it's so hard for me to find an answer from google, your interpretation makes sense very much!

Best regards,
Weixing
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840886 is a reply to message #1840784] Wed, 28 April 2021 07:32 Go to previous messageGo to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Dear Christian,

The code of Ecore2Xtext looks wonderful, and I have imported into MENIFEST, but how do I use it? Because the detailed process of generation of Xtext usually is implicit or backstage, how can I use Ecore2Xtext plugin to instead of the default process?

Best regards,
Weixing
Re: How could I create a new Xtext project from existing ecore model then there is no brackets in xt [message #1840901 is a reply to message #1840886] Wed, 28 April 2021 13:05 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you may import the plugin to your codebase, patch it, start a runtime workspace and use the wizard in that.
you sure can somehow script it, but therefore you needs to look what the wizard does.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:On-the-fly declaration in cross-reference
Next Topic:Nested class and visibility of members
Goto Forum:
  


Current Time: Thu Apr 18 13:32:38 GMT 2024

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

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

Back to the top