eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

Unused variable included in the extracted method after using "Extract to method" code action

Open gayalkuruppu opened this issue 1 year ago • 0 comments

Refer the following scenario.

In here, the unused variable a is there in the extracted() method, which can be removed with the original extract to method code action.

https://user-images.githubusercontent.com/46120162/180372491-9b81c367-bb8a-411e-b080-cf5b6d398d04.mov

Code to reproduce:

public class Extract {

    public static void main(String[] args) {
        int a;
        int b = 1;
        a = 1;
        b = a + b;
    }
}

Expected output:

public class Extract {

    public static void main(String[] args) {
        int a;
        int b = extracted();
        a = 1;
        b = a + b;
    }

    private static int extracted() {
        int b = 1;
        return b;
    }
}

gayalkuruppu avatar Jul 22 '22 05:07 gayalkuruppu