Bug 191943 - [api] JavaCore.getGeneratedResources(IRegion, boolean) for IType
Summary: [api] JavaCore.getGeneratedResources(IRegion, boolean) for IType
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-11 08:35 EDT by Martin Aeschlimann CLA
Modified: 2007-06-28 06:15 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2007-06-11 08:35:48 EDT
3.3

I would also like to pass in an IType (from a source file) to JavaCore.getGeneratedResources(IRegion, boolean) and get the corresponding class file.
At the moment the region is limited to ICompilationUnit and parent elements.

Mapping an IType to a class file is not trivial when anonymous classes or local types are involved.
Comment 1 Martin Aeschlimann CLA 2007-06-11 09:13:11 EDT
Actually i think it's not only non-trivial, but not possible at all.

We don't have a method getBinaryName on IType so it's not clear which resource from JavaCore.getGeneratedResources maps to which IType.
Comment 2 Olivier Thomann CLA 2007-06-11 10:01:06 EDT
No need for an API.
You can use an AST with binding resolved + an AST visitor and it works.
-1 for a new API
Comment 3 Martin Aeschlimann CLA 2007-06-11 10:27:09 EDT
Can you elaborate, maybe a code snipped? I don't have an AST, just an IType...

I believe this is a common use case (see the discussions in bug 6584). If it's more than 5-10 lines of code I would say it makes sense if JavaCore.getGeneratedResources can support this.
Also it's expensive to build an AST, and JavaCore.getGeneratedResources maybe has more efficient ways to do the mapping.