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: 34
Registered: April 2019
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: 14665
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()


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: Thu Apr 25 00:11:40 GMT 2024

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

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

Back to the top