IDEA-166827 Quick-fix to insert SAM-method call

This commit is contained in:
Tagir Valeev
2017-01-23 12:55:51 +07:00
parent 05a7c64272
commit 8f904a0d06
14 changed files with 197 additions and 5 deletions

View File

@@ -0,0 +1,10 @@
// "Insert '.doSomething' to call functional interface method" "true"
public class Test {
interface MyFn {
void doSomething(String s, int i);
}
public void test(MyFn fn) {
fn.doSomething();
}
}

View File

@@ -0,0 +1,8 @@
// "Insert '.apply' to call functional interface method" "true"
import java.util.function.Function;
public class Test {
public void test(Function<String, String> fn) {
String res = fn.apply("foo");
}
}

View File

@@ -0,0 +1,11 @@
// "Insert '.test' to call functional interface method" "true"
import java.util.function.Function;
import java.util.function.Predicate;
public class Test {
public void test(Predicate<String> predicate) {
if(predicate.test("foo")) {
}
}
}

View File

@@ -0,0 +1,10 @@
// "Insert '.doSomething' to call functional interface method" "true"
public class Test {
interface MyFn {
void doSomething(String s, int i);
}
public void test(MyFn fn) {
fn(<caret>);
}
}

View File

@@ -0,0 +1,8 @@
// "Insert '.apply' to call functional interface method" "true"
import java.util.function.Function;
public class Test {
public void test(Function<String, String> fn) {
String res = f<caret>n("foo");
}
}

View File

@@ -0,0 +1,11 @@
// "Insert '.doSomething' to call functional interface method" "false"
public class Test {
interface MyFn {
void doSomething(String s, int i);
void doSomething();
}
public void test(MyFn fn) {
fn(<caret>);
}
}

View File

@@ -0,0 +1,11 @@
// "Insert '.test' to call functional interface method" "true"
import java.util.function.Function;
import java.util.function.Predicate;
public class Test {
public void test(Predicate<String> predicate) {
if(predi<caret>cate("foo")) {
}
}
}