Bug 115040

Summary: Provide API for getting occurrence count from initializers and types
Product: [Eclipse Project] JDT Reporter: Philip Mayer <eclipsetalk2>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: markus.kell.r
Version: 3.2   
Target Milestone: 3.2 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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