Community
Participate
Working Groups
Current API lets us get an AST with binding from an ICompilationUnit. We have all the information needed from the ICompilationUnit (source, name, project), but we don't actually have an ICompilationUnit object. Request the following API to allow generation of ASTs with binding without an ICompilationUnit: public static CompilationUnit parseCompilationUnit(char[] source, String unitName, IJavaProject javaProject, boolean resolveBindings)
Created attachment 462 [details] Because we needed this API for our implementation, we made the necessary changes ourselves. They may or may not be interesting to implementors of this feature.
I wonder why you need to provide an IJavaProject and a boolean resolveBinding. I consider this as redundant. I would suggest to provide null for the IJavaProject if you don't want to resolve bindings.
We might not need a new API if you can use a working copy instead of a ICompilationUnit. Would this be useful for you?
Yes, it is redundant, if I provide an IJavaProject, I want to resolve bindings. I don't need the boolean resolveBinding. Furthermore, if I don't want to resolve bindings, I can use parseCompilationUnit(char[]).
What do you have in hand when you want to call this new API? I'd like to find out if using a working copy is a viable solution for you. I think it is ok. Then we don't need to change anything.
What I have, is the source code of a compilation unit I just generated, the name of this compilation unit and the project where I want to compile it. This modification is for evaluate expressions in a debug context. How that works ? I create a source code with the skeleton (method and field declarations) of the type where the debugger stops, I add a magic method at the right place, get the corresponding AST of this code, find the magic method in the AST and generate an equivalent instruction set. In common cases, for generate the magic source code, I use the original type source from the compilation unit. But if the type is a binary type (no source), I ask the vm for informations about the type and create the magic source code with these. If you know a way to create a ICompilationUnit (or a WorkingCopy) from a binary type, I can use the actual API, otherwise I think I need this new method.
We have read-only working copies for IClassfile, but these would be helpful here. Olivier, please go for the source based API addition.
I removed the boolean. If the java project is null, then a parsing is done without any binding resolution.
Fixed and released in HEAD.