mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
RefactoringUtil#ensureCodeBlock enhanced and used in Surround with try-catch
Fixes IDEA-178781 "Surround with try-catch" QuickFix for "Unhandled exception" in a field initializer Enables stream-to-loop in field initializer Fixes stream-to-loop in for initializer Disables stream-to-loop in for update
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
public class Main {
|
||||
String j = "foo";
|
||||
|
||||
public void test(List<String> list) {
|
||||
long i = 0L;
|
||||
for (String s : list) {
|
||||
if (s.isEmpty()) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for(;
|
||||
i<10;
|
||||
i+=list.stream().filter(String::isEmpty).count()) {
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
{
|
||||
long j = 0L;
|
||||
for (String s : list) {
|
||||
if (s.isEmpty()) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for(;
|
||||
j<10;
|
||||
j+=list.stream().filter(String::isEmpty).count()) {
|
||||
System.out.println(j);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(j);
|
||||
|
||||
StringJoiner joiner = new StringJoiner(",");
|
||||
for (String s1 : list) {
|
||||
joiner.add(s1);
|
||||
}
|
||||
for(String s = joiner.toString(); !s.isEmpty(); s = s.substring(1)) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Main().test(Arrays.asList("", "", "foo"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user