Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customize Java-Expression "toString"(Customizing NodeModelUtils getTokenText)
Customize Java-Expression "toString" [message #1843730] Mon, 16 August 2021 09:19 Go to next message
Frä Fröhlich is currently offline Frä FröhlichFriend
Messages: 22
Registered: June 2021
Junior Member
I am using JBase with Java-Expressions my project.
Luckily, when I am parsing my rules and want to print the entered input of the user I can easily call
NodeModelUtils.getTokenText(NodeModelUtils.findActualNodeFor(object))
. Let's call this the "toString" Method for the rest of this thread.

While this is very helpful I couldn't figure out how it works in details since it is very low level implemented. I wanted to introduce tiny changes to the "toString" Method. I.e. I want to introduce a namespace for the variables(a = 5; should become MyNameSpace.a = 5;). Furthermore, I would like to enforce line endings "\n" to not get converted to whitespaces like it is the case in the getTokenText Method.

I couldn't find an entry point where to start.
Can You help?
Re: Customize Java-Expression "toString" [message #1843733 is a reply to message #1843730] Mon, 16 August 2021 10:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14283
Registered: July 2009
Senior Member
i dont understand this question.
if you dont like what NodeModelUtils.getTokenText(NodeModelUtils.findActualNodeFor(object))
why dont you traverse the nodemodel yourself..


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Customize Java-Expression "toString" [message #1843734 is a reply to message #1843733] Mon, 16 August 2021 10:25 Go to previous messageGo to next message
Frä Fröhlich is currently offline Frä FröhlichFriend
Messages: 22
Registered: June 2021
Junior Member
The traversal of a "simple" java statement like in JBase is quite complex because it has multiple branches and attributes.
I thought there is a different way of getting the string. Since the NodeModelUtils doesn't have access to structure of my models, there must be a way to get the string without traversing.
Nonetheless, I can't really understand the fundamentals of what this class actually does with all this composite nodes.

If there is no such way of customizing the nodeutils, then I will have to traverse the whole grammar myself.
Re: Customize Java-Expression "toString" [message #1843736 is a reply to message #1843734] Mon, 16 August 2021 10:55 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14283
Registered: July 2009
Senior Member
for structure and generic toString check org.eclipse.xtext.util.EmfFormatter.objToStr(Object, EStructuralFeature...)

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Validating against non EMF context
Next Topic:Concurrent readers impossible?
Goto Forum:
  


Current Time: Wed Jun 29 01:53:39 GMT 2022

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

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

Back to the top