Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Customize Java-Expression "toString"(Customizing NodeModelUtils getTokenText)
Customize Java-Expression "toString" [message #1843730] Mon, 16 August 2021 05:19 Go to next message
Eclipse UserFriend
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 06:04 Go to previous messageGo to next message
Eclipse UserFriend
i dont understand this question.
if you dont like what NodeModelUtils.getTokenText(NodeModelUtils.findActualNodeFor(object))
why dont you traverse the nodemodel yourself..
Re: Customize Java-Expression "toString" [message #1843734 is a reply to message #1843733] Mon, 16 August 2021 06:25 Go to previous messageGo to next message
Eclipse UserFriend
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 06:55 Go to previous message
Eclipse UserFriend
for structure and generic toString check org.eclipse.xtext.util.EmfFormatter.objToStr(Object, EStructuralFeature...)
Previous Topic:Validating against non EMF context
Next Topic:Concurrent readers impossible?
Goto Forum:
  


Current Time: Sun Jun 15 05:31:35 EDT 2025

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

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

Back to the top