Bug 318448

Summary: [extract method] Should move @SuppressWarnings annotation while extracting method
Product: [Eclipse Project] JDT Reporter: Tomasz Bartczak <kretes>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, markus.kell.r, Olivier_Thomann
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: fix candidate

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.