mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
LambdaGenerationUtil#canBeUncheckedLambda: supports statements; checks control-flow breaks;
Fix for IDEA-165369 Replace Optional.isPresent() should be disabled if the thenBranch contains non-local control flow
This commit is contained in:
+1
@@ -4,6 +4,7 @@ import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public void testOptional(Optional<String> str) {
|
||||
if (str == null) str = Optional.empty();
|
||||
str.ifPresent(System.out::println);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "INFORMATION"
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
for(String arg : args) {
|
||||
Optional<String> opt = Optional.of("xyz");
|
||||
opt.ifPresent(s -> {
|
||||
System.out.println(s);
|
||||
System.out.println(s);
|
||||
Runnable r = () -> {
|
||||
return;
|
||||
};
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (i == 3) continue;
|
||||
System.out.println(arg);
|
||||
if (i == 5)
|
||||
break;
|
||||
|
||||
}
|
||||
System.out.println(s);
|
||||
throw new RuntimeException();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -4,6 +4,7 @@ import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public void testOptional(Optional<String> str) {
|
||||
if (str == null) str = Optional.empty();
|
||||
if (str.isPrese<caret>nt()) {
|
||||
System.out.println(str.get());
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "false"
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
for(String arg : args) {
|
||||
Optional<String> opt = Optional.of("xyz");
|
||||
if (opt.isPre<caret>sent()) {
|
||||
System.out.println(opt.get());
|
||||
System.out.println(opt.get());
|
||||
Runnable r = () -> {return;};
|
||||
for(int i=0; i<10; i++) {
|
||||
if(i == 3) continue;
|
||||
System.out.println(arg);
|
||||
if(i == 5)
|
||||
break;
|
||||
|
||||
}
|
||||
System.out.println(opt.get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "false"
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
for(String arg : args) {
|
||||
Optional<String> opt = Optional.of("xyz");
|
||||
if (opt.isPre<caret>sent()) {
|
||||
System.out.println(opt.get());
|
||||
System.out.println(opt.get());
|
||||
Runnable r = () -> {return;};
|
||||
for(int i=0; i<10; i++) {
|
||||
if(i == 3) continue;
|
||||
System.out.println(arg);
|
||||
if(i == 5)
|
||||
break;
|
||||
|
||||
}
|
||||
System.out.println(opt.get());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "INFORMATION"
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
for(String arg : args) {
|
||||
Optional<String> opt = Optional.of("xyz");
|
||||
if (opt.isPre<caret>sent()) {
|
||||
System.out.println(opt.get());
|
||||
System.out.println(opt.get());
|
||||
Runnable r = () -> {return;};
|
||||
for(int i=0; i<10; i++) {
|
||||
if(i == 3) continue;
|
||||
System.out.println(arg);
|
||||
if(i == 5)
|
||||
break;
|
||||
|
||||
}
|
||||
System.out.println(opt.get());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user