eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
Unused variable included in the extracted method after using "Extract to method" code action
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;
}
}