Community
Participate
Working Groups
Nested annotation element completion fails for element names when the same element name has been specified in the root annotation. This only occurs when no elements have been specified in the nested annotation element. The following illustrates the problem: public @interface RootAnnotation { String x() default ""; NestedAnnotation []nestedAnnotation() default {}; } public @interface NestedAnnotation { String x() default ""; String y() default ""; String z() default ""; } public class NestedAnnotationCompletionTest { @RootAnnotation(x="foo", nestedAnnotation={@NestedAnnotation()}) String foo; } In the NestedAnnotationCompletionTest, when the cursor is inside the @NestedAnnotation parens and code completion invoked, the displayed element completions will be 'y' and 'z', with 'x' missing from the list. This appears to be related to the existence of an element of the same name having been specified in the @RootAnnotation. If this is removed, or x/y/z is specified in the @NestedAnnotation, then the completions offered will be x/y/z as expected. This has the potential to be confusing to a user that is unfamiliar with the available elements for a given annotation. This particular case can be observed in several JPA annotation configurations.
Created attachment 183436 [details] test case
Doing content assist at <code assist here> using 3.6.1 or 3.7 M3 with your code loaded into a new workspace: public class NestedAnnotationCompletionTest { @RootAnnotation(x="foo", nestedAnnotation={@NestedAnnotation(<code assist here>)}) String foo; } I can't reproduce the problem i.e. I get x,y and z proposed.
(In reply to comment #2) > I can't reproduce the problem i.e. I get x,y and z proposed. Interesting. I'm using the following build, but do have other plugins loaded that could perhaps be involved. I'll do some testing with a pure JDT environment. Version: 3.7.0 Build id: I20101028-1441
I can reproduce the problem in HEAD. Moving to JDT Core, since we don't get the proposal for "x" in org.eclipse.jdt.ui.text.java.CompletionProposalCollector.accept(..)
Neil, the problem is that I tried with the attached test case from comment 1 which is not reproducing the issue since "x="foo" is missing there. When I use the snippets from comment 0 I can also reproduce the problem.
Created attachment 183677 [details] Corrected test case Sorry Dani, I must have exported after re-verifying the functional state. Here is a correct test case for future reference.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Still an issue in 4.12 M1.