Bug 115040 - Provide API for getting occurrence count from initializers and types
Summary: Provide API for getting occurrence count from initializers and types
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-04 04:36 EST by Philip Mayer CLA
Modified: 2005-12-13 06:49 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Mayer CLA 2005-11-04 04:36:47 EST
I am writing code similar to CompilationUnit#findElements(), but not similar
enough to be able to directly call that method. 

I need to be able to re-locate an existing initializer or anonymous type inside
a new type or new method. IMethod contains a method getType(String name, int
occurrenceCount) and IType contains a method getInitializer(int
occurrenceCount). It is however not possible to retrieve the occurence count of
an existing initializer or a type with API methods.

I cannot use the parents' element type lists or initializer lists to relocate
the initializer or type, as those methods require the parent to exist.

So, the request is for a method "int getOccurrenceCount()" in IInitializer and
IType.

Philip
Comment 1 Markus Keller CLA 2005-11-04 05:33:12 EST
We also wouldn't mind if the method was added on ISourceReference, although
IInitializer and IType would be sufficient for now.
Comment 2 Markus Keller CLA 2005-11-22 09:42:53 EST
Could this PR be considered for 3.2 (or even M4)?

We currently cast to the internal SourceRefElement to get at this information, but we shouldn't ship like this ;-)
Comment 3 Jerome Lanneluc CLA 2005-11-24 07:14:12 EST
The occurrence count doesn't really make sense for an IClassFile or an ICompilationUnit, so it cannot be on ISourceReference. Instead I added IMember#getOccurrenceCount().

Also added tests CompilationUnitTests#testGetOccurrenceCount01/02.
Comment 4 David Audel CLA 2005-12-13 06:49:19 EST
Verified for 3.2 M4 using build I20051212-0010