Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to get AST from plugin project
icon5.gif  How to get AST from plugin project [message #760041] Thu, 01 December 2011 04:55 Go to next message
Jeff  is currently offline Jeff Friend
Messages: 7
Registered: November 2011
Junior Member
Ok, so what I'm trying to do is create an eclipse plugin that displays a graph of part of a language's AST.

I've been looking, but the closest thing I can find is the org.eclipse.emf.transaction.listeners extension point, but I'm not sure if this will work, given that none of the projects extend the org.eclipse.emf.transaction.editingDomains extension point, at least as far as I can see.

Is there an extension point that I can extend, or something that I can add to the xtext generator which will let me get at this?

[Updated on: Thu, 01 December 2011 23:46]

Report message to a moderator

Re: How to get AST from plugin project [message #760338 is a reply to message #760041] Thu, 01 December 2011 23:45 Go to previous messageGo to next message
Jeff  is currently offline Jeff Friend
Messages: 7
Registered: November 2011
Junior Member
So, I'm still stuck on this.
Every time a project is built from my DSL, it generates java code from an AST.
All I'm looking for is to hook into the AST at that point. How do I do this?
Re: How to get AST from plugin project [message #760354 is a reply to message #760338] Fri, 02 December 2011 06:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
On 01/12/2011 23:45, Jeff wrote:
> So, I'm still stuck on this.
> Every time a project is built from my DSL, it generates java code from
> an AST.
> All I'm looking for is to hook into the AST at that point. How do I do
> this?
Look for the *.ecore file; it is a (meta-)model

Regards

Ed Willink
Re: How to get AST from plugin project [message #760478 is a reply to message #760338] Fri, 02 December 2011 14:04 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Not sure I understand your question.

Your DSL (x) is expressed in a grammar x.xtext.
Xtext generates (among other things) an ecore model (x.ecore).
EMF then generates Java code - an implementation of this model.

Later an instance of your language x.dsl is parsed by the generated
parser and an instance of the ecore.model is created.
At this point, you may have a builder that generates Java code for this
model (i.e. x.java).

What exactly is it you want to process? The x.ecore, or the model of an
x.dsl ?

Regards
- henrik

On 2011-02-12 24:45, Jeff wrote:
> So, I'm still stuck on this.
> Every time a project is built from my DSL, it generates java code from
> an AST.
> All I'm looking for is to hook into the AST at that point. How do I do
> this?
Re: How to get AST from plugin project [message #760725 is a reply to message #760478] Sun, 04 December 2011 20:58 Go to previous messageGo to next message
Jeff  is currently offline Jeff Friend
Messages: 7
Registered: November 2011
Junior Member
The model of an x.dsl.
I think I may have figured out a way of doing it, but I'm not sure if it's right - I'll have a shot at it, but any tips are appreciated.
Re: How to get AST from plugin project [message #760811 is a reply to message #760725] Mon, 05 December 2011 10:46 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
You could have a look at: https://github.com/dslmeinte/EMF-Statistics-View (fork)
Also, "Visualizing the AST" in http://dslmeinte.wordpress.com/2010/09/06/tricks-for-implementing-scoping/ explains how to do this manually in Eclipse.


Re: How to get AST from plugin project [message #760813 is a reply to message #760725] Mon, 05 December 2011 10:47 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2011-04-12 21:58, Jeff wrote:
> The model of an x.dsl.
> I think I may have figured out a way of doing it, but I'm not sure if
> it's right - I'll have a shot at it, but any tips are appreciated.

A builder would probably work the best.
- henrik
Re: How to get AST from plugin project [message #761181 is a reply to message #760811] Tue, 06 December 2011 03:26 Go to previous message
Jeff  is currently offline Jeff Friend
Messages: 7
Registered: November 2011
Junior Member
Quote:
You could have a look at: [link](fork)
Also, "Visualizing the AST" in [link] explains how to do this manually in Eclipse.


Thanks Meinte, that stats view project was really helpful - just what I needed. Very Happy
Previous Topic:advanced qualified names
Next Topic:String to Integer Conversion in Xtend2
Goto Forum:
  


Current Time: Thu Mar 28 23:10:57 GMT 2024

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

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

Back to the top