Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to access the ASTs that Eclipse uses?
How to access the ASTs that Eclipse uses? [message #247778] Tue, 18 September 2007 07:34 Go to next message
Eclipse UserFriend
Hello,
Is there any way that one can access the ASTs that Eclipse uses? I
suppose Eclipse has it's own set of ASTs for every Java source file of a
Java Project at any given moment. I would like to be able to visit those
ASTs instead of doing both parsing and visiting for an ICompilationUnit.
Or is this impossible, does Eclipse only have the JavaModel and
parses & visits only when it needs to ?

Thank you
George
Re: How to access the ASTs that Eclipse uses? [message #247809 is a reply to message #247778] Tue, 18 September 2007 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"George Ganea" <georgeganea@gmail.com> wrote in message
news:e0a3cc8e32f46bb471c20dba426000fc$1@www.eclipse.org...
> Hello,
> Is there any way that one can access the ASTs that Eclipse uses? I
> suppose Eclipse has it's own set of ASTs for every Java source file of a
> Java Project at any given moment. I would like to be able to visit those
> ASTs instead of doing both parsing and visiting for an ICompilationUnit.

See
http://www.eclipse.org/articles/article.php?file=Article-Jav aCodeManipulation_AST/index.html
Re: How to access the ASTs that Eclipse uses? [message #247846 is a reply to message #247809] Wed, 19 September 2007 04:36 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote:

>"George Ganea" <georgeganea@gmail.com> wrote in message
>news:e0a3cc8e32f46bb471c20dba426000fc$1@www.eclipse.org...
>
>
>>Hello,
>> Is there any way that one can access the ASTs that Eclipse uses? I
>>suppose Eclipse has it's own set of ASTs for every Java source file of a
>>Java Project at any given moment. I would like to be able to visit those
>>ASTs instead of doing both parsing and visiting for an ICompilationUnit.
>>
>>
>
>See
> http://www.eclipse.org/articles/article.php?file=Article-Jav aCodeManipulation_AST/index.html
>
>
And in 3.4 see also: org.eclipse.jdt.ui.SharedASTProvider

Dani
Re: How to access the ASTs that Eclipse uses? [message #247874 is a reply to message #247846] Wed, 19 September 2007 12:18 Go to previous messageGo to next message
Eclipse UserFriend
Thank you both,
Up until now I've designed my plugin to work just like in the article
(I've actually used that exact same article as a startup point).

But if I want, for example, to collect all the local variables of a
given type (the AST nodes that represent those local variables to be more
exact) from a java project, i'd have to parse all the source files and
then visit the ASTs... - I'd like to skip the parsing phase and do only
the visiting.

My question is, can I skip this step, does the Eclipse IDE have
somewere all the ASTs form a given JavaProject, or does every plugin,
(e.g. the editor) needs to parse it's own ASTs when it's needs to.
I'm using Eclipse 3.3 and I haven't tried
org.eclipse.jdt.ui.SharedASTProvider yet, I'll download 3.4 tomorrow :)

thanks again,
George
Re: How to access the ASTs that Eclipse uses? [message #247894 is a reply to message #247874] Wed, 19 September 2007 14:45 Go to previous messageGo to next message
Eclipse UserFriend
George Ganea a écrit :
> My question is, can I skip this step, does the Eclipse IDE have
> somewere all the ASTs form a given JavaProject, or does every plugin,
> (e.g. the editor) needs to parse it's own ASTs when it's needs to.
I believe only the current editor has its AST available.
Having all the ASTs in memory simply would not scale.
If you need clues on how to create all the ASTs for a java project, let
me know.
--
Olivier
Re: How to access the ASTs that Eclipse uses? [message #247984 is a reply to message #247894] Fri, 21 September 2007 07:45 Go to previous message
Eclipse UserFriend
Olivier Thomann wrote:

> George Ganea a écrit :
>> My question is, can I skip this step, does the Eclipse IDE have
>> somewere all the ASTs form a given JavaProject, or does every plugin,
>> (e.g. the editor) needs to parse it's own ASTs when it's needs to.
> I believe only the current editor has its AST available.
> Having all the ASTs in memory simply would not scale.

Ok, thank you very much for your answer, I was hoping I could get those
ASTs for free... Oh well, I'll just have to parse the java files for
myself...

I was amazed how quickly the SearchEngine (org.eclipse.jdt.core.search)
returns the results, that's why I thought that the ASTs should be already
there, but then I looked at the source code and noticed it too uses a sort
of a parser...

http://kickjava.com/src/org/eclipse/jdt/internal/core/search /BasicSearchEngine.java.htm


Thank you all,
George
Previous Topic:Confirming quit before exiting no longer works
Next Topic:Changing Java source in a builder; which mechanism?
Goto Forum:
  


Current Time: Thu May 08 16:01:18 EDT 2025

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

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

Back to the top