|
|
Re: How get XtextEditor starting from a node of document AST? [message #1021905 is a reply to message #1021818] |
Wed, 20 March 2013 22:55 |
Steve Kallestad Messages: 62 Registered: March 2013 |
Member |
|
|
It sounds to me like you have a document node, and you want to get to the top level of the document to reference another part. For example:
blog:
author : Steve
url : http://www.steve.com
article:
title : how to get poor quickly
date : 1/1/2013
article:
title : I don't understand this jargon just yet
date : 3/25/2013
You have a reference to a title node, and you want to get to the root node of the file so you can figure out who the author is.
There are a couple of ways to do it.
1st and I think more recommended than trying to parse the entire tree is to use cross-references. There's a good series of articles here on how it works http://blogs.itemis.de/stundzig/archives/773. It took me a little while to grasp all the jargon - being new to xtext, but if your patient enough to absorb it, there's a lot of good information in there.
Otherwise, I *think* from a given node, you can get it's Container with node.eContainer(). You'll want to write a recursive function that follows the eContainer objects until you get to the root. (eContainer().eContainer().eContainer() ... )
I'm no expert, but if it was me, I'd throw a little code together, run it through the debugger and see if I couldn't find a way to navigate.
XText is based on EMF, so you might want to look through EMF Modelling documentation and other resources on how to navigate a model.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03185 seconds