Parse java source code out of workspace [message #187760] |
Tue, 30 November 2004 03:57  |
Eclipse User |
|
|
|
Originally posted by: outiejun.hotmail.com
Hello everyone:
I have a question about parsing a java source code out of workspace.
The existing method in JDT provided is base on the Java Project in the
workspace, and my problem is that I want to read a single java source
without compilation, and parse it in order to get the information(such as
method, class name, and package name, etc.) from that .java file.
Is there any way to reach this in JDT or any other solution.
Any help would be appreciated.
|
|
|
|
|
|
Re: Parse java source code out of workspace [message #188019 is a reply to message #188012] |
Wed, 01 December 2004 10:29   |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
A little clarification about the CompilationUnit. Everytime I go to it I
think it should list the methods and such. But then I realize, again
:-), that the compilation unit is the entire java file, not the class.
So what you get directly from the CU is the imports, package, and list
of types. It is within each type that you see methods, fields, etc. A CU
can contain more than one type, but in general that is not a good idea.
It makes maintanance harder.
Rich Kulp wrote:
> The header comment for ASTParser has the example. The resulting
> CompilationUnit is a logical tree structure of the parsed java class.
> Using accessors on the CompilationUnit will give you the info you need.
>
>
--
Thanks,
Rich Kulp
|
|
|
|
Powered by
FUDForum. Page generated in 0.03593 seconds