Bug 550431 - [quick assist] Combine selected annotations into a composed annotation
Summary: [quick assist] Combine selected annotations into a composed annotation
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.13   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-26 03:31 EDT by Noopur Gupta CLA
Modified: 2020-08-12 02:27 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.