Bug 330622 - [content assist] Nested annotation element code completion fails in specific case
Summary: [content assist] Nested annotation element code completion fails in specific ...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 330600
  Show dependency tree
 
Reported: 2010-11-18 17:22 EST by Neil Hauge CLA
Modified: 2023-04-09 05:21 EDT (History)
4 users (show)

See Also:


Attachments
test case (710 bytes, application/zip)
2010-11-18 17:28 EST, Neil Hauge CLA
no flags Details
Corrected test case (718 bytes, application/zip)
2010-11-23 10:45 EST, Neil Hauge CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Hauge CLA 2010-11-18 17:22:58 EST
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.
Comment 1 Neil Hauge CLA 2010-11-18 17:28:38 EST
Created attachment 183436 [details]
test case
Comment 2 Dani Megert CLA 2010-11-23 06:12:06 EST
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.
Comment 3 Neil Hauge CLA 2010-11-23 09:25:34 EST
(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
Comment 4 Markus Keller CLA 2010-11-23 10:13:15 EST
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(..)
Comment 5 Dani Megert CLA 2010-11-23 10:34:13 EST
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.
Comment 6 Neil Hauge CLA 2010-11-23 10:45:35 EST
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.
Comment 7 Eclipse Genie CLA 2019-04-16 02:32:39 EDT
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.
Comment 8 Dani Megert CLA 2019-04-16 10:21:29 EDT
Still an issue in 4.12 M1.
Comment 9 Eclipse Genie CLA 2021-04-06 06:51:06 EDT
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.
Comment 10 Eclipse Genie CLA 2023-04-09 05:21:51 EDT
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.