Bug 209778 - [search] TypeReferenceMatch#getOtherElements() fails for match in annotation
Summary: [search] TypeReferenceMatch#getOtherElements() fails for match in annotation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-14 07:15 EST by Markus Keller CLA
Modified: 2009-08-05 05:45 EDT (History)
3 users (show)

See Also:


Attachments
Proposed patch (21.58 KB, patch)
2009-03-06 05:58 EST, Frederic Fusier CLA
no flags Details | Diff
Update patch for 3.6 (22.62 KB, patch)
2009-06-19 11:14 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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