Bug 550431

Summary: [quick assist] Combine selected annotations into a composed annotation
Product: [Eclipse Project] JDT Reporter: Noopur Gupta <noopur_gupta>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, kaiwinter, pyvesdev, sam, theit
Version: 4.13   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Noopur Gupta CLA 2019-08-26 03:31:58 EDT
Add a quick assist to combine selected annotations into a composed annotation.

For example, see: https://stackoverflow.com/questions/57629096/how-to-reuse-junit-jupiter-methodsource-for-multiple-parameterized-tests/57629806?stw=2#57629806

@ParameterizedTest
@MethodSource("example.Testing#text()")
void A(String text) {
    System.out.println(text);
}

If the user selects the following in the above example:
@ParameterizedTest
@MethodSource("example.Testing#text()")

there can be a quick assist to combine them into a composed annotation type:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@ParameterizedTest
@MethodSource("example.Testing#text()")
public @interface ParameterizedTextTest {
}

We need to check the configuration of the selected annotation types.

We can also open the "New Annotation Type" dialog with the quick assist if it is required for configuration from the user.
Comment 1 Sam Brannen CLA 2019-08-26 08:23:45 EDT
Thanks for creating the ticket!

> We need to check the configuration of the selected annotation types.

Agreed. 

The @Retention should probably default to RetentionPolicy.RUNTIME.

And the @Target should likely be created by a "plausible" combination of the targets for the meta-annotations.

For example, if none of the meta-annotations has a target of TYPE, then the new composed annotation also should not have a target of TYPE.

> We can also open the "New Annotation Type" dialog with the quick assist if it is required for configuration from the user.

That also sounds viable.

For the new composed annotation, it would also be nice if @Documented and @Inherited are taken into consideration.