- fix UnnecessaryArrayCreationFix to calculate where to start looking
for methods that might match if array creation is unwrapped
- for super method calls, constructor calls, calls from expression,
and static method calls where the method is imported, use the
declaring class of the method called; otherwise use the
enclosing class where the call is made
- also check for nested classes and allow matches for private
methods found in enclosing class
- add new tests and reformat some of UnnecessaryArrayCreationFix
Given:
public class A {
public class ChildClass extends A {
public void overloadedMethod(int number) {
}
public void doNotCallAnotherMethod(int number) {
overloadedMethod(new int[]{number});
}
}
public void overloadedMethod(int... numbers) {
}
}
Applying "Remove unnecessary array creation" cleanup should not
change the overloadedMethod() call because an existing method with
a single int argument exists.
Change-Id: Id45393641d8cd078e2d8a2a769f8a623add7fb6c
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/178974
Tested-by: JDT Bot <jdt-bot@eclipse.org>