Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Access a model element from a value converter
Access a model element from a value converter [message #1779725] Thu, 11 January 2018 19:54 Go to next message
Pent Down is currently offline Pent DownFriend
Messages: 4
Registered: January 2018
Junior Member
Hello,

I my grammar I have an element like this:

Project:
'PROJECT' (description=STRING)?
'UNITS'
'LENGTH' lengthUnitDefault=UNIT
'SPEED' speedUnitDefault=UNIT

This element is instantiated first. Down the road I need to access the lengthUnitDefault data member from a IValueConverter. How to I 'grab' the Project element?

Sorry this may be obvious but I am learning XText.

Regards
PD
Re: Access a model element from a value converter [message #1779734 is a reply to message #1779725] Thu, 11 January 2018 22:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12397
Registered: July 2009
Senior Member
Have a look at the passsed node

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Access a model element from a value converter [message #1779738 is a reply to message #1779734] Thu, 11 January 2018 23:44 Go to previous message
Pent Down is currently offline Pent DownFriend
Messages: 4
Registered: January 2018
Junior Member
Thank you for the help

I use the node to get up in the AST and then use NodeModelUtils.findActualSemanticObjectFor(node) to get to it:

def getMyEObject(INode node) {
var tmpNode = node
while (tmpNode !== null) {
var o = NodeModelUtils.findActualSemanticObjectFor(tmpNode)
if (o !== null) {
if (o instanceof MyEObject) {
return o as MyEObject
}
}
tmpNode = tmpNode.parent
}
}
Previous Topic:@Traced and getting rid of the traces
Next Topic:Problem while creating the issues on other resources
Goto Forum:
  


Current Time: Tue Nov 20 14:05:31 GMT 2018

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

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

Back to the top