Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 520618

Summary: [content assist] Typing annotation value doesn't work
Product: [Eclipse Project] JDT Reporter: Yauheniy Ratkevich <evser11>
Component: CoreAssignee: Jeff Johnston <jjohnstn>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: jjohnstn
Version: 4.8   
Target Milestone: 4.11   
Hardware: PC   
OS: Windows NT   
Whiteboard:

Description Yauheniy Ratkevich CLA 2017-08-07 07:28:06 EDT
When I want a hint for annotation like this:

@interface MyAnnotation {
    Object any() default null;
    String value default "";
}

For this case content assist work correctly:
| - cursor

@MyAnnotation(value=|)

But for this case content assist fails:

@MyAnnotation(|)

Like no attribute was chosen.
Comment 1 Jeff Johnston CLA 2019-11-07 18:47:42 EST
The following annotation:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD) //can use in method only.
public @interface MyAnnotation {
	
	String enabled() default "false";
	String name() default "Jeff";

}

and the following Test:

public class TestAnnotation {
	
	@MyAnnotation(|) // cursor inside parentheses


	public void foo() {
		
	}

works fine in latest Eclipse and in 2019-03 a fix was made to add the equal sign for a selection.  The content assist proposes the two possible selections: "enabled" and "name"

When either is selected, the code adds "enabled = " or "name = " and once one is added, the other is presented in subsequent content assist

(e.g. @MyAnnotation(enabled = "true", |) <== this will offer name

}