mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract method: new signature detector: add unused parameters to method calls as refs to initial vars
This commit is contained in:
@@ -1219,6 +1219,8 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
}
|
||||
methodCallExpression.getArgumentList().add(val);
|
||||
}
|
||||
} else {
|
||||
methodCallExpression.getArgumentList().add(myElementFactory.createExpressionFromText(data.variable.getName(), methodCallExpression));
|
||||
}
|
||||
}
|
||||
return match.replace(myExtractedMethod, methodCallExpression, myOutputVariable);
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class Test {
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
<selection>System.out.println("foo".substring(x));</selection>
|
||||
|
||||
System.out.println("bar".substring(x));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
public class Test {
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
newMethod(x, "foo".substring(x));
|
||||
|
||||
newMethod(x, "bar".substring(x));
|
||||
}
|
||||
|
||||
private void newMethod(int x, String substring) {
|
||||
System.out.println(substring);
|
||||
}
|
||||
}
|
||||
@@ -627,6 +627,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testSuggestChangeSignatureInitialParameterUnused() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testSuggestChangeSignatureWithChangedParameterName() throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
boolean success = performExtractMethod(true, true, getEditor(), getFile(), getProject(), false, null, false, "p");
|
||||
|
||||
Reference in New Issue
Block a user