mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
introduce code block parameter: extract method call with conditional exit
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
void bar() {
|
||||
void bar() {
|
||||
foo(1, new Consumer<Integer>() {
|
||||
public void accept(Integer i) {
|
||||
System.out.println(i);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
void bar() {
|
||||
void bar() {
|
||||
foo(1, new Consumer<Integer>() {
|
||||
public void accept(Integer i) {
|
||||
System.out.println(i);
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
class Test {
|
||||
void bar() {
|
||||
foo(1, new IntPredicate() {
|
||||
public boolean test(int i) {
|
||||
if (i > 0) {
|
||||
System.out.println(i);
|
||||
System.out.println(i);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void foo(int i, IntPredicate anObject) {
|
||||
|
||||
if (anObject.test(i)) return;
|
||||
|
||||
System.out.println("Hi");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Test {
|
||||
void bar() {
|
||||
void bar() {
|
||||
foo(new Runnable() {
|
||||
public void run() {
|
||||
System.out.println("");
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
void bar() {
|
||||
foo(1);
|
||||
}
|
||||
|
||||
void foo(int i) {
|
||||
<selection>
|
||||
if (i > 0) {
|
||||
System.out.println(i);
|
||||
System.out.println(i);
|
||||
return;
|
||||
}
|
||||
</selection>
|
||||
System.out.println("Hi");
|
||||
}
|
||||
}
|
||||
+11
-3
@@ -26,15 +26,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
@TestDataPath("$CONTENT_ROOT/testData")
|
||||
public class IntroduceFunctionalParameterTest extends LightRefactoringTestCase {
|
||||
public void testSampleRunnable() throws Exception {
|
||||
doTest(null);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntConsumer() throws Exception {
|
||||
doTest(null);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntConsumerFromIfStatement() throws Exception {
|
||||
doTest(null);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntPredicateConditionalExit() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -53,6 +57,10 @@ public class IntroduceFunctionalParameterTest extends LightRefactoringTestCase
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(null);
|
||||
}
|
||||
|
||||
private void doTest(String conflict) {
|
||||
boolean enabled = true;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user