You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Nyttle Veliath <ny...@sg.systemaccess.com> on 2007/03/14 10:53:46 UTC

parsing a Java Source File

Hi ,

I have a requirement to parse the Java source in order to find out all the 
associations used by that class. 
I tried with your JaxmeJS framework and I have some problems in gettint 
the imported packages.

JavaSource.getImports(). length() returns 0 eventhough the source file has 
got 5 import statements.

Another thing I am looking for is, by using this framework, I am not able 
to list out those classes within the same package being referred in the 
source file.
Also, if there are some classes which are not declared by import 
statements, but useed witht their fully qualified names, these are also 
not  identified .

I need to get all dependedent classes /associations used in the specified 
Java Source. 

Please help me if you have some ideas.
Nyttle George * System Analyst * SunGard * System Access * #28-01, 8 
Temasek Boulevard, Suntec Tower Three, Singapore 038988 * Tel 65 6335 3603 
* Mobile 65 93894201 * Email nyttle.veliath@sungard.com * Fax 65 6333 4133 
* www.sungard.com/systemaccess

Re: parsing a Java Source File

Posted by Jochen Wiedmann <jo...@gmail.com>.
Hi,

first of all, please be so kind to subscribe to the mailing list. If
you aren't subscribed, then I have to approve all mails manually.


On 3/14/07, Nyttle Veliath <ny...@sg.systemaccess.com> wrote:

> JavaSource.getImports(). length() returns 0 eventhough the source file has
> got 5 import statements.

Possibly a bug that can be fixed. File a bug report.


> Another thing I am looking for is, by using this framework, I am not able to
> list out those classes within the same package being referred in the source
> file.
> Also, if there are some classes which are not declared by import statements,
> but useed witht their fully qualified names, these are also not  identified.
>
> I need to get all dependedent classes /associations used in the specified
> Java Source.

Unfortunately, the framework won't be of much help in its current state.

The JS framework provides access to

  - the syntactical representation of a source file (as opposed to
    the semantics)
  - to the signature (fields, methods, inner classes, .., as opposed to
    the actual code contained therein)

Your requests would definitely require at least some semantics. For
example, if you use a class "Foo", then the framework should have some
possibility to work out, whether you want "Foo" in the same package,
or "java.lang.Foo", or an inner class "Foo", or whatever. This
possibility does not exist. I can imagine that this could be added,
but won't be the one to implement it.

You've got to know for yourself, whether the second aspect is required
too. If so, you're better off using an AntLR grammar (as the JS
framework itself does) or something like that. (Note, that you still
would miss the semantic level.)

Jochen

-- 
Emacs 22 will support MacOS and CygWin. It is not yet decided, whether
these will be used to run Emacs or the other way round.

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org