mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
extract method: allow to fold parameters if calls to fields are involved
This commit is contained in:
+1
-1
@@ -270,7 +270,7 @@ public class ParametersFolder {
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiVariable) {
|
||||
final PsiVariable variable = (PsiVariable)resolved;
|
||||
if (!inputVariables.contains(variable)) {
|
||||
if (!(variable instanceof PsiField) && !inputVariables.contains(variable)) {
|
||||
localVarsUsed[0] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Main {
|
||||
private String [] args;
|
||||
|
||||
void foo(Main m, int i) {
|
||||
<selection>if (m.args[i] != null) {
|
||||
System.out.println(m.args[i]);
|
||||
}</selection>
|
||||
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Main {
|
||||
private String [] args;
|
||||
|
||||
void foo(Main m, int i) {
|
||||
newMethod(m.args[i]);
|
||||
|
||||
}
|
||||
|
||||
private void newMethod(String arg) {
|
||||
if (arg != null) {
|
||||
System.out.println(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,6 +344,9 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFoldingWithFieldInvolved() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV11748() throws Exception {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user