Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How get XtextEditor starting from a node of document AST?
How get XtextEditor starting from a node of document AST? [message #1021651] Wed, 20 March 2013 13:09 Go to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Hi. Smile

Starting from any node of the AST model representing an XtextDocument, is there a way to obtain the XtextEditor in which this document is opened for editing?

I need this because, on changes to AST model by user typing, I'd want to trigger some ui actions in the editor.


Thanks in advance,
Marco
Re: How get XtextEditor starting from a node of document AST? [message #1021818 is a reply to message #1021651] Wed, 20 March 2013 18:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14670
Registered: July 2009
Senior Member
Hi,

am not quite sure why you need an XtextEditor. can you please elaborate how you get the xtext document and how you listen to changes and what kind of action you want to trigger?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 Go to previous messageGo to next message
Steve Kallestad is currently offline Steve KallestadFriend
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.
Re: How get XtextEditor starting from a node of document AST? [message #1027132 is a reply to message #1027098] Tue, 26 March 2013 15:36 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14670
Registered: July 2009
Senior Member
Hi,

the document is created by the XtextDocumentProvider afaik.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How to obtain EMF model at certain offset
Next Topic:Proxies
Goto Forum:
  


Current Time: Sat Apr 27 04:43:18 GMT 2024

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

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

Back to the top