Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] parser question

Hey!

I need to create ASTs (incl. type resolving) for Java source files (outside of an Eclipse project environment, just plain Java and some source files).
At the moment I am using:

ASTParser parser = ASTParser.newParser(AST.JLS11);

This works nicely, but I need to get ASTs for method bodies, so I configured the parser to NOT ignore method bodies. But this causes the parser to somehow call out to a compiler to generate bytecode - which I don’t need at all for my purpose. I am interested in the resolved AST only, no byte code necessary. Since this piece of the code is extremely sensitive to performance and memory footprint issues, I am looking into this.

Is there an alternative to this approach to avoid the bytecode generation?

I found this:
org.eclipse.jdt.internal.compiler.parser.Parser
but I have no idea how to use that or how to configure that to generate an AST from source files.

Can you shed some light on this? Any examples how to re-use this parser for generating ASTs (without bytecode generation)?

Thanks so much for your help!
-Martin





Back to the top