Bug 569028 - [quickfix] "Remove 'x', keep assignments with side effects" does not update method calls
Summary: [quickfix] "Remove 'x', keep assignments with side effects" does not update m...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.17   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Jeff Johnston CLA
QA Contact: Fabrice Tiercelin CLA
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-22 03:31 EST by Fabrice Tiercelin CLA
Modified: 2023-06-24 15:49 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabrice Tiercelin CLA 2020-11-22 03:31:06 EST
Given:
private void myMethod() {
  methodWithUunusedParam(123);
}

private void methodWithUunusedParam(int unused) {
}

When:
Clicking on "Remove 'unused', keep assignments with side effects"

Then:
private void myMethod() {
  methodWithUunusedParam(123);
                         ^^^
}

private void methodWithUunusedParam() {
}

Compilation error.


When a method parameter (let's name it 'x') is not used in the method body, there is the warning "The value of the parameter x is not used". 5 quickfixes are available. The first one is "Remove 'x', keep assignments with side effects". If you click on the quickfix, the parameter is removed on the method signature but the method calls are not updated. In other words, the values passed as the parameter are still passed and the signature of the call becomes wrong.

Currently, if a user wants to use this quickfix, the user should rather right-click on the method, click on Refactor -> Change the Method Signature... -> Select the parameter, click on remove and click on OK. Doing so, so behavior is correct.

The quickfix should do the same. It should refactor the whole project. It seems that the code should be edited here:
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/tree/org.eclipse.jdt.core.manipulation/core%20extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFixCore.java?id=c63ac951840bb1149dd72111d963b0129d9df235#n225
Comment 1 Kalyan Prasad Tatavarthi CLA 2021-02-15 01:59:18 EST
ping!
Comment 2 Eclipse Genie CLA 2023-06-24 15:49:36 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.