Using ASTParser with binding resolving in a standalone application [message #253189] |
Tue, 06 May 2008 05:28  |
Eclipse User |
|
|
|
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 #253350 is a reply to message #253336] |
Wed, 14 May 2008 03:53  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04763 seconds