Bug 519384 - [override method] Generating code to override method should copy annotations of super method
Summary: [override method] Generating code to override method should copy annotations ...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-07 07:49 EDT by Simeon Andreev CLA
Modified: 2017-07-14 11:45 EDT (History)
3 users (show)

See Also:


Attachments
Java project with which the problem can be reproduced (2.25 KB, application/zip)
2017-07-07 07:49 EDT, Simeon Andreev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2017-07-07 07:49:15 EDT
Created attachment 269280 [details]
Java project with which the problem can be reproduced

It seems this was tracked with bug report 353472, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=353472.

However with 4.6 I don't observe that all annotations are copied from the super method. An example of this is the @Before annotation for junit4, or e.g. @OverridingMethodsMustInvokeSuper.


To reproduce

1. Import project from attached zip.
2. Open type SomeSub.
3. Generated code to override method someMethod.


Observed behavior

The following code is generated:

@Override
public void someMethod() {
    // TODO Auto-generated method stub
    super.someMethod();
}


Desired behavior

Since the super method has the @Before annotation, the generated method should have it as well. So the generated code, in this case, should be as follows:

@Before
@Override
public void someMethod() {
    // TODO Auto-generated method stub
    super.someMethod();
}

I can reproduce this with:

Version: Neon.3+ (4.6.3)
Build id: R20170220-0833
Comment 1 Andrey Loskutov CLA 2017-07-07 08:11:00 EDT
Looks like the fix for bug 353472 was reverted via bug 386410. :-(

Looks like one can't either enable it by default for all, not disable by default for all without make someone angry.

What about to enable this by default for a list of known annotations, which can be extended by user? By default we could have @Before @After etc in the list.