Bug 225310

Summary: ContentAssist should not show annotations that are not valid for the current location
Product: [Eclipse Project] JDT Reporter: Philipp Kursawe <phil.kursawe>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, david_audel, jerome_lanneluc
Version: 3.4   
Target Milestone: 3.4 M7   
Hardware: All   
OS: All   
Whiteboard:

Description Philipp Kursawe CLA 2008-04-02 07:46:04 EDT
Build ID: I20080330-1350

Steps To Reproduce:
1. Type '@' and press CTRL+Space to activate the content assist above a Method
2. It will show all annotations, even those whose target is set to "ElementType.TYPE"

More information:
The content assist should check if the annotation is actually possible at the current location and not provide it otherwise.
Comment 1 David Audel CLA 2008-04-03 07:40:54 EDT
All annotations are proposed but annotations whose target is set to ElementType.METHOD are proposed first.

----------------------------
@Target(ElementType.TYPE)
public @interface MyAnnot1 {
}
----------------------------
Target(ElementType.METHOD)
public @interface MyAnnot2 {
}
----------------------------
public class Test {
  @MyAnnot| // do ctrl+space at | location
  public void foo() {}
}
----------------------------

With this test case MyAnnot1 and MyAnnot2 are proposed but MyAnnot2 is at the top of the list of proposals.
MyAnnot1 must not be filtered because perhaps the user want to type:

public class Test {
  @MyAnnot1 class X {}
  public void foo() {}
}

I close this bug as INVALID because it works as designed.
Comment 2 Philipp Kursawe CLA 2008-04-03 07:53:16 EDT
You are right David, I did not thought of this use-case. Well done!
Comment 3 Jerome Lanneluc CLA 2008-04-28 07:17:38 EDT
Was verified for 3.4M7 by reporter (comment 2)