Bug 237369 - [quick fix] Remove argument quick fix could guess which parameter to remove
Summary: [quick fix] Remove argument quick fix could guess which parameter to remove
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-16 17:32 EDT by Benjamin Muskalla CLA
Modified: 2008-10-27 04:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2008-06-16 17:32:16 EDT
I20080613-2000

Having a method with several parameters of the same type and removing the paramter in the method declaration leads to compile error. Invoking the quick fix to "Remove argument" this could guess which paramters should be removed and not the first one in every case.

package A;

public class E {

	void foo() {
		String foo= "";
		String param= "";
		String bar= "";
		bar(foo, param, bar);   <- invoke quick fix "Remove Argument"
	}

	private void bar(String foo, /* String param, */ String bar) {
	}
}

I wish that the "Remove argument" quick fix could guess that the 2nd paramter should be removed according to the names of the given arguments. If the names do not match (or it's not possible due to binary classes) it should behave as it does at the moment.
Comment 1 Martin Aeschlimann CLA 2008-06-17 05:20:08 EDT
Nice to have, but how often does it happen that arguments are matching the parameter names? Is it worth the extra analysis?
Comment 2 Benjamin Muskalla CLA 2008-06-17 05:39:49 EDT
At least in the JDT source itself i stumbled across several places where this fits into the picture.
One example is the DefaultProblem ctor which is often called where the arguments match the parameter names.
Comment 3 Benjamin Muskalla CLA 2008-10-26 18:54:24 EDT
In addition to the name matching mechanism as stated in comment #0 it could be implemented with the types in mind.

package A;

public class E {

	void foo() {
		String foo= "";
		int param= 5;
		boolean bar= true;
		bar(foo, param, bar);   <- invoke quick fix "Remove Argument"
	}

	private void bar(String foo, /* int param, */ boolean bar) {
	}
}