Bug 11125 - DOM/AST: API request
Summary: DOM/AST: API request
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-11 15:34 EST by Luc Bourlier CLA
Modified: 2002-03-13 12:20 EST (History)
0 users

See Also:


Attachments
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. (2.83 KB, text/plain)
2002-03-11 15:35 EST, Luc Bourlier CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luc Bourlier CLA 2002-03-11 15:34:22 EST
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)
Comment 1 Luc Bourlier CLA 2002-03-11 15:35:29 EST
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.
Comment 2 Olivier Thomann CLA 2002-03-12 11:14:20 EST
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.
Comment 3 Olivier Thomann CLA 2002-03-12 11:26:13 EST
We might not need a new API if you can use a working copy instead of a ICompilationUnit. Would this be 
useful for you?
Comment 4 Luc Bourlier CLA 2002-03-12 11:33:10 EST
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[]).
Comment 5 Olivier Thomann CLA 2002-03-12 11:38:55 EST
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.
Comment 6 Luc Bourlier CLA 2002-03-12 12:32:55 EST
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.

Comment 7 Philipe Mulet CLA 2002-03-13 04:50:54 EST
We have read-only working copies for IClassfile, but these would be helpful 
here.

Olivier, please go for the source based API addition.
Comment 8 Olivier Thomann CLA 2002-03-13 12:01:19 EST
I removed the boolean. If the java project is null, then a parsing is done without any binding 
resolution.
Comment 9 Olivier Thomann CLA 2002-03-13 12:20:05 EST
Fixed and released in HEAD.