Bug 209778

Summary: [search] TypeReferenceMatch#getOtherElements() fails for match in annotation
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc, philippe_mulet, srikanth_sankaran
Version: 3.4   
Target Milestone: 3.6 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Update patch for 3.6 none

Description Markus Keller CLA 2007-11-14 07:15:56 EST
HEAD, found while looking at bug 155013 comment 21

TypeReferenceMatch#getOtherElements() does not return the other elements if a match is inside an annotation.

Steps:
- have:
---------------------
package xy;

public class Try {
	void tryB(int tryKind) {
		@Constants(Try.class) int tryCopy, tryCopy2= tryKind;
	}
	@Constants(value= Try.class) Object fTryA, fTryB;
}

@interface Constants {
	Class<?> value();
}
---------------------

- Refactor > Rename type "Try" using dialog
  - choose "update similarly named ..."
  - click "Configure..." and choose 3rd strategy

- click Next

=> TypeReferenceMatch#getOtherElements() is null for both reported matches, but it should return ILocalVariable 'tryCopy2' and IField 'fTryB'.

If the proposal from bug 155013 comment 22 is implemented, it should return IAnnotations in #getLocalElement() and #getOtherElements().
Comment 1 Philipe Mulet CLA 2008-02-13 08:39:22 EST
Could defer until 3.5 since not super critical. 
Nice to have though for API completeness.
So time permitting for M6.

Comment 2 Frederic Fusier CLA 2008-03-23 12:25:11 EDT
Finally, the last patch released for bug 209996 does not fix the problem described in comment 0. However, note that with that fix applied, the refactoring does no longer try to rename fields and local variables in the given snippet...
Comment 3 Jerome Lanneluc CLA 2008-05-02 04:46:34 EDT
We ran out of time for 3.4M7.
Comment 4 Frederic Fusier CLA 2009-03-06 05:58:44 EST
Created attachment 127796 [details]
Proposed patch

Markus, please let me know if this fix would match your expectation, thanks
Comment 5 Markus Keller CLA 2009-03-16 12:23:09 EDT
> Markus, please let me know if this fix would match your expectation, thanks

Looks good. I would only add an example in the Javadoc of TypeReferenceMatch#getOtherElements() where an IAnnotation is returned.
Comment 6 Frederic Fusier CLA 2009-06-19 11:14:59 EDT
Created attachment 139643 [details]
Update patch for 3.6

Updated patch for 3.6 including example in TyepReferenceMatch.getOtherElements() javadoc comment...
Comment 7 Frederic Fusier CLA 2009-06-19 11:16:59 EDT
Released for 3.6M1 in HEAD stream.
Comment 8 Srikanth Sankaran CLA 2009-08-05 05:45:52 EDT
Verified for 3.6M1 using I20090803-1800