mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
Java: Don't fold the whole extracted expression (IDEA-195927)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
class C {
|
||||
int x;
|
||||
|
||||
int b(boolean[] b, C[] c, int n) {
|
||||
int i = n;
|
||||
while (i >= 0 && (<selection>b[i] || c[n].x == c[i].x</selection>)) {
|
||||
i--;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int a(boolean[] b, C[] c, int n) {
|
||||
int i = n;
|
||||
while (i < c.length && (b[i] || c[n].x == c[i].x)) {
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
class C {
|
||||
int x;
|
||||
|
||||
int b(boolean[] b, C[] c, int n) {
|
||||
int i = n;
|
||||
while (i >= 0 && newMethod(b[i], c[n].x == c[i].x)) {
|
||||
i--;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private boolean newMethod(boolean b2, boolean b1) {
|
||||
return b2 || b1;
|
||||
}
|
||||
|
||||
int a(boolean[] b, C[] c, int n) {
|
||||
int i = n;
|
||||
while (i < c.length && (newMethod(b[i], c[n].x == c[i].x))) {
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,12 +2,12 @@ import java.util.List;
|
||||
class C {
|
||||
void foo(int[] a, List<Integer> b) {
|
||||
int i = 1;
|
||||
int n = newMethod(bar(a[i], b.get(i)));
|
||||
int n = newMethod(a[i], b.get(i));
|
||||
System.out.println(n);
|
||||
}
|
||||
|
||||
private int newMethod(int bar) {
|
||||
return bar;
|
||||
private int newMethod(int a, Integer b) {
|
||||
return bar(a, b);
|
||||
}
|
||||
|
||||
int bar(int a, int b) {
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
public class Test {
|
||||
String foo(String[] s, int i) {
|
||||
return newMethod(s[i]);
|
||||
return newMethod(s, i);
|
||||
}
|
||||
|
||||
private String newMethod(String s) {
|
||||
return s;
|
||||
private String newMethod(String[] s, int i) {
|
||||
return s[i];
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
String arg = newMethod(args[0]); //comment
|
||||
String arg = newMethod(args); //comment
|
||||
}
|
||||
|
||||
private static String newMethod(String arg) {
|
||||
return arg;
|
||||
private static String newMethod(String[] args) {
|
||||
return args[0];
|
||||
}
|
||||
}
|
||||
@@ -1291,6 +1291,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testDuplicateSubexpression() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testBeforeCommentAfterSelectedFragment() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user