Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » how to get an xtext expression as a java string from an ecore object(ecore to xtext to string)
how to get an xtext expression as a java string from an ecore object [message #1732176] Fri, 13 May 2016 09:35 Go to next message
Alexandre Le Borgne is currently offline Alexandre Le BorgneFriend
Messages: 2
Registered: May 2016
Junior Member
Hi!

I'm currently trying to develop a sirius graphical editor with Xtext integration.

I wrote an Xtext grammar that derived my ecore metamodel so everything is good so far.

The problem I'm now facing is that I would like to be able to represent one of my Xtext concepts as a Java string in my graphical editor.

For instance:
Let's say we have a simple xtext expression like
Expression :
(left = INT op='+' right=Expression)
| Expression1;
(with several levels to handle priorities)

What I would like to do is to write an expression like "1+1" into as the label a graphical box instead of having to create a lot of boxes in the graphical editor which would be awful since expressions may be kind of recursive (if I write 1+1+1+1+1+1+1+1 it gets to be that ugly that the concept of graphical editor doesn't makes sense anymore...)

So my question is : How do I get the Xtext expression that is written in my example file from the ecore object that represents this expression? And how can I get this expression as a Java String I could return to my graphical model?

Thanks!
Re: how to get an xtext expression as a java string from an ecore object [message #1732221 is a reply to message #1732176] Fri, 13 May 2016 13:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
You can use NodeModelUtils to retrieve the node for your eobject and ask the node for its text

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: how to get an xtext expression as a java string from an ecore object [message #1732225 is a reply to message #1732221] Fri, 13 May 2016 14:14 Go to previous message
Alexandre Le Borgne is currently offline Alexandre Le BorgneFriend
Messages: 2
Registered: May 2016
Junior Member
Thank you so much for your answer that was exactly what I needed!! Smile
Previous Topic:P2 update site for latest builds broken?
Next Topic:How to configure xtend-maven-plugin to target earlier Java versions
Goto Forum:
  


Current Time: Sat Apr 27 03:33:07 GMT 2024

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

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

Back to the top