Bug 318448 - [extract method] Should move @SuppressWarnings annotation while extracting method
Summary: [extract method] Should move @SuppressWarnings annotation while extracting me...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: fix candidate
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-30 08:16 EDT by Tomasz Bartczak CLA
Modified: 2010-09-01 11:51 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Bartczak CLA 2010-06-30 08:16:29 EDT
Build Identifier: 20100617-1415

when I'm extracting method that has some code covered by @SuppressWarnings - annotation is not transfered to extracted method, which causes additional warnings.

Example:

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void extractMethodTest(List list) {
        list.add("");
    }

Annotation @SuppressWarnings is covering first line of this method.
Now I extract list.add(""); to a new method and get:

 @SuppressWarnings({ "unchecked", "rawtypes" })
    public void extractMethodTest(List list) {
        extracted(list);
    }

    private boolean extracted(List list) {
        return list.add("");
    }

while it shoule be

    @SuppressWarnings({ "rawtypes" })
    public void extractMethodTest(List list) {
        extracted(list);
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private boolean extracted(List list) {
        return list.add("");
    }

to keep the rule that if something was suppressed it should be suppressed after refactoring.



Reproducible: Always
Comment 1 Olivier Thomann CLA 2010-06-30 08:17:32 EDT
Move to JDT/UI
Comment 2 Dani Megert CLA 2010-07-29 04:26:38 EDT
Would be a cool feature to actually move and/or copy the corresponding @SuppressWarnings annotation so that the amount of problems stays the same.