Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Can we access the java parser AST?
Can we access the java parser AST? [message #25707] Thu, 01 May 2003 11:21 Go to next message
Eclipse UserFriend
Originally posted by: ademar.aguiar.fe.up.pt

I would like to have access to the abstract syntax tree (AST) of a java file
opened in a project, for visiting it and generating a specific
representation of the java file more useful for my needs than the source
code text itself.

Is this possible within the Eclipse platform to access this AST?
If yes, how? Are there any extension points? Examples? Documentation?

Thanks a lot!

Ademar

FEUP, Porto, Portugal
ademar.aguiar@fe.up.pt
Re: Can we access the java parser AST? [message #25886 is a reply to message #25707] Thu, 01 May 2003 11:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Olivier_Thomann.ca.ibm.comNOSPAM

On Thu, 1 May 2003 16:21:39 +0100, "Ademar Aguiar"
<ademar.aguiar@fe.up.pt> wrote:
>Is this possible within the Eclipse platform to access this AST?
>If yes, how? Are there any extension points? Examples? Documentation?
You should have a look at the org.eclipse.jdt.core plugin and the AST
class.
org.eclipse.jdt.core.dom.AST.parseCompilationUnit(....).
Once you have your AST tree, you can visit it using a visitor (define
your subclass of org.eclipse.jdt.core.dom.ASTVisitor.
--
Olivier
Re: Can we access the java parser AST? [message #26045 is a reply to message #25886] Thu, 01 May 2003 12:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ademar.aguiar.fe.up.pt

I was there already in org.eclipse.jdt.core plugin but haven't seen yet the
AST class, but only the JavaCore class and JavaElement classes...
Having this ASTVisitor is great, but unfortunately it seems not to be easy
to handle original comments and formatting.

Thanks a lot for your answer!

Ademar


"Olivier Thomann" <Olivier_Thomann@ca.ibm.comNOSPAM> wrote in message
news:neg2bv4vkjqkst47hmbjtgo23ulaoq3ofv@4ax.com...
> On Thu, 1 May 2003 16:21:39 +0100, "Ademar Aguiar"
> <ademar.aguiar@fe.up.pt> wrote:
> >Is this possible within the Eclipse platform to access this AST?
> >If yes, how? Are there any extension points? Examples? Documentation?
> You should have a look at the org.eclipse.jdt.core plugin and the AST
> class.
> org.eclipse.jdt.core.dom.AST.parseCompilationUnit(....).
> Once you have your AST tree, you can visit it using a visitor (define
> your subclass of org.eclipse.jdt.core.dom.ASTVisitor.
> --
> Olivier
Re: Can we access the java parser AST? [message #26369 is a reply to message #26045] Thu, 01 May 2003 13:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Olivier_Thomann.ca.ibm.comNOSPAM

On Thu, 1 May 2003 17:42:09 +0100, "Ademar Aguiar"
<ademar.aguiar@fe.up.pt> wrote:
>to handle original comments and formatting.
This two items are on our list.

Inside the JDT/UI plugin, there is a first version of AST rewriting
(it is internal, btu you might want to have a look). Then you can use
a code formatter on the resulting string.
--
Olivier
Re: Can we access the java parser AST? [message #26475 is a reply to message #26369] Thu, 01 May 2003 14:02 Go to previous message
Eclipse UserFriend
Originally posted by: ademar.aguiar.fe.up.pt

Ok, I will try to download JDT sources and then take a look at that AST
rewriter.

Thanks a lot!

Ademar

"Olivier Thomann" <Olivier_Thomann@ca.ibm.comNOSPAM> wrote in message
news:dum2bv8kbiea1419uleda69bo6t8dalrfl@4ax.com...
> On Thu, 1 May 2003 17:42:09 +0100, "Ademar Aguiar"
> <ademar.aguiar@fe.up.pt> wrote:
> >to handle original comments and formatting.
> This two items are on our list.
>
> Inside the JDT/UI plugin, there is a first version of AST rewriting
> (it is internal, btu you might want to have a look). Then you can use
> a code formatter on the resulting string.
> --
> Olivier
Previous Topic:How Do I Debug A Servlet?
Next Topic:using an external jar
Goto Forum:
  


Current Time: Mon May 12 14:45:19 EDT 2025

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

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

Back to the top