Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Using ASTParser with binding resolving in a standalone application
Using ASTParser with binding resolving in a standalone application [message #253189] Tue, 06 May 2008 05:28 Go to next message
Eclipse UserFriend
Hello all

I have written a plugin that does some AST Parsing with binding
resolving. Now I need to do the same outside of eclipse, in a standalone
application.
To have binding resolving, I need a configured project (as far as I
understood). To have a project, I need a workspace.

I have found a lot of snippets on how to create a project inside a
plugin. But how do I:
1. create a new workspace <-- how to do that
2. set up a new project
3. add the files (jars, java sources, ...)
4. Perform some AST analyzing
5. shut down the project and workspace
6. delete the complete workspace with the project

The question now is: How do I programmatically create a new workspace
from scratch?
Something like "ResourcesPlugin.getPlugin().start(BundleContext?);"?
Steps 2 to 4 are ok. 5 and 6 should be intuitive once knowing step 1.


Any help? Hints? Similar applications/snippets? Is it even possible?
Or is there an easier way of getting the bindings? I am able to do some
AST parsing without binding resolving in my standalone application by
providing the source as char[].


thanks
Marco
Re: Using ASTParser with binding resolving in a standalone application [message #253270 is a reply to message #253189] Tue, 13 May 2008 03:26 Go to previous messageGo to next message
Eclipse UserFriend
"Marco Trudel" <marco@mtsystems.ch> wrote in message
news:fvp8ct$7sq$1@build.eclipse.org...
> The question now is: How do I programmatically create a new workspace from
> scratch?

You might want to take a look at the JDT Builder test plug-in (which you can
get from CVS). The JDT tests have to do just what you're describing.
Sorry, I don't have a workspace open right now so I can't give you the exact
class to look at.
Re: Using ASTParser with binding resolving in a standalone application [message #253331 is a reply to message #253270] Tue, 13 May 2008 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote:
> "Marco Trudel" <marco@mtsystems.ch> wrote in message
> news:fvp8ct$7sq$1@build.eclipse.org...
>> The question now is: How do I programmatically create a new workspace from
>> scratch?
>
> You might want to take a look at the JDT Builder test plug-in (which you can
> get from CVS).

Thanks for your answer. I now checked out
org.eclipse.jdt.core.tests.builder. Is this the correct directory?

> The JDT tests have to do just what you're describing.

I looked at the source files but didn't find a the code to create a
workspace from scratch (only the usual ResourcesPlugin.getWorkspace()).
But of course I might have missed it (or got the wrong directory).

> Sorry, I don't have a workspace open right now so I can't give you the exact
> class to look at.

A snippet for what I have to look for or, if I got the wrong directory,
the correct one would be great.


Thanks for your time
Marco
Re: Using ASTParser with binding resolving in a standalone application [message #253336 is a reply to message #253331] Tue, 13 May 2008 20:08 Go to previous messageGo to next message
Eclipse UserFriend
"Marco Trudel" <marco@mtsystems.ch> wrote in message
news:4829EC8E.4030706@mtsystems.ch...
> Thanks for your answer. I now checked out
> org.eclipse.jdt.core.tests.builder. Is this the correct directory?
>
> I looked at the source files but didn't find a the code to create a
> workspace from scratch (only the usual ResourcesPlugin.getWorkspace()).
> But of course I might have missed it (or got the wrong directory).


Ah, yes, you're correct. I'm starting to get a clearer picture of what
you're trying to do, and unfortunately I don't think you can do it. If I
understand, you're hoping to use the classes in org.eclipse.jdt.core.dom,
outside of the context of an Eclipse executable. I'm not an expert, but I
don't believe that's possible. The DOM AST classes have dependencies on
classes (e.g., IPath) that are defined by the Eclipse runtime. I think if
it is working at all right now you might just be getting lucky... Is there
some reason that this has to be a standalone application?
Re: Using ASTParser with binding resolving in a standalone application [message #253350 is a reply to message #253336] Wed, 14 May 2008 03:53 Go to previous message
Eclipse UserFriend
Walter Harley wrote:
> "Marco Trudel" <marco@mtsystems.ch> wrote in message
> news:4829EC8E.4030706@mtsystems.ch...
>> Thanks for your answer. I now checked out
>> org.eclipse.jdt.core.tests.builder. Is this the correct directory?
>>
>> I looked at the source files but didn't find a the code to create a
>> workspace from scratch (only the usual ResourcesPlugin.getWorkspace()).
>> But of course I might have missed it (or got the wrong directory).
>
>
> Ah, yes, you're correct. I'm starting to get a clearer picture of what
> you're trying to do, and unfortunately I don't think you can do it.

Well, Eclipse is doing it, so there's no logical reason why I couldn't
do it. The only question is how and how hard it will get.

> If I
> understand, you're hoping to use the classes in org.eclipse.jdt.core.dom,
> outside of the context of an Eclipse executable.

Exactly. Simple AST parsing without binding resolving of Java source
files as char[] works perfectly. These jars are needed in order to make
this work outside the Eclipse context:
- org.eclipse.core.contenttype_3.2.100.v20070319.jar
- org.eclipse.core.jobs_3.3.1.R33x_v20070709.jar
- org.eclipse.core.resources_3.3.1.R33x_v20080205.jar
- org.eclipse.core.runtime_3.3.100.v20070530.jar
- org.eclipse.equinox.common_3.3.0.v20070426.jar
- org.eclipse.equinox.preferences_3.2.101.R33x_v20080117.jar
- org.eclipse.jdt.core_3.3.3.v_793_R33x.jar
- org.eclipse.osgi_3.3.2.R33x_v20080105.jar

> I'm not an expert, but I
> don't believe that's possible. The DOM AST classes have dependencies on
> classes (e.g., IPath) that are defined by the Eclipse runtime. I think if
> it is working at all right now you might just be getting lucky...

AST parsing is straight forward. I don't think it's luck that it works.
But as soon as binding resolving comes into the game, it gets harder and
a real Eclipse project is needed (probably on a PC of a enduser that
does not have Eclipse installed).

> Is there
> some reason that this has to be a standalone application?

Well, having an end-user application that does some AST processing is
nothing special nowadays. And since the eclipse AST parser is excellent,
it would be great to also have access to the bindings.
In my case, Java AST parsing is a little part of a large project that
doesn't fit into Eclipse.


thanks
Marco
Previous Topic:How to change debug highlighting color?
Next Topic:Compiler and multi-core
Goto Forum:
  


Current Time: Thu Sep 18 01:19:48 EDT 2025

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

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

Back to the top