Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing parser source correspondence for AST elements in standalone setup
Accessing parser source correspondence for AST elements in standalone setup [message #1805055] Fri, 05 April 2019 04:37 Go to next message
Ben Holland is currently offline Ben HollandFriend
Messages: 12
Registered: April 2019
Junior Member
Hi all,

I'm trying to build some static analysis tooling of an XText DSL and I need to access the source correspondences (token start and offset positions in the parsed source file). I can see how one would normally access this information in the formatting2 stubs via the GrammarAccess injections, but I am currently running XText in a standalone setup using a resource set so I am confused how to retrieve this information outside of the formatting2 context.

For the Greetings example how would I find the token start and end offsets of each name?
Re: Accessing parser source correspondence for AST elements in standalone setup [message #1805079 is a reply to message #1805055] Fri, 05 April 2019 13:09 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13164
Registered: July 2009
Senior Member
Hi you can use NodeModelUtils to gain access to the nodemodel. you can also do
org.eclipse.xtext.resource.XtextResource.getParseResult()
and org.eclipse.xtext.parser.IParseResult.getRootNode()


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Get all syntax errors
Next Topic:Operators for operations with java.lang.Number
Goto Forum:
  


Current Time: Tue Oct 22 20:00:47 GMT 2019

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

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

Back to the top