mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
IDEA-166636 A bunch of bugs in TrivialFunctionalExpressionUsageInspection (Method call can be simplified)
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
/* comment1 */
|
||||
|
||||
System.out.println(/* output x */"a"+/* who-hoo */ "x");
|
||||
|
||||
// comment2
|
||||
System.out.println("hello");
|
||||
/*in return */
|
||||
String s = "foo" + //inline
|
||||
"bar";
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("hello");
|
||||
Collections.singleton("abc").contains("ab");
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
Supplier<String> s = () -> {
|
||||
System.out.println("hello");
|
||||
return "foo";
|
||||
};
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if(list.isEmpty()) {
|
||||
System.out.println("foo");
|
||||
list.add("foo");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -2,5 +2,6 @@
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
String s = "";
|
||||
// comment
|
||||
String s = "";
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
/* bar */
|
||||
/* who-hoo */
|
||||
String s = "foo";
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
/* bar */
|
||||
String s = ("a" +/* who-hoo */ "x") + "foo";
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
String s = ((Function<String, String>) ((x) -> {
|
||||
/* comment1 */
|
||||
|
||||
System.out.println(/* output x */x);
|
||||
|
||||
// comment2
|
||||
System.out.println("hello");
|
||||
return /*in return */ "foo" + //inline
|
||||
"bar";
|
||||
})).<caret>apply("a"+/* who-hoo */ "x");
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
((Predicate<String>) ((x) -> {
|
||||
System.out.println("hello");
|
||||
return Collections.singleton("abc").contains(x);
|
||||
})).<caret>test("ab");
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
Supplier<String> s = () -> ((Supplier<String>)() -> {
|
||||
System.out.println("hello");
|
||||
return "foo";
|
||||
}).<caret>get();
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if(list.isEmpty())
|
||||
((Consumer<String>) x -> {
|
||||
System.out.println(x);
|
||||
list.add(x);
|
||||
}).<caret>accept("foo");
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace method call on lambda with lambda body" "false"
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
((Predicate<String>)((x) -> {
|
||||
if (x.length() > 0) {
|
||||
return x.startsWith("a");
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
})).<caret>test("ab");
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace method call on lambda with lambda body" "false"
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
while(((Predicate<String>) ((x) -> {
|
||||
System.out.println("hello");
|
||||
return Collections.singleton("abc").contains(x);
|
||||
})).<caret>test("ab")) {
|
||||
System.out.println("hello");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -3,6 +3,7 @@ import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
String s = ((Supplier<String>) () -> {
|
||||
// comment
|
||||
return "";
|
||||
}).g<caret>et();
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
String s = ((Function<String, String>)((x) -> /* bar */ "foo")).a<caret>pply("a" +/* who-hoo */ "x");
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace method call on lambda with lambda body" "true"
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
String s = ((Function<String, String>)((x) -> /* bar */ x + "foo")).a<caret>pply("a" +/* who-hoo */ "x");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user