FoldExpressionIntoStream: support String.join-able patterns (IDEA-190570)

This commit is contained in:
Tagir Valeev
2018-05-11 16:25:05 +07:00
parent 78c37f99f7
commit ca3f94d456
7 changed files with 123 additions and 28 deletions
@@ -0,0 +1,9 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
// "Fold expression into Stream chain" "true"
class Test {
void test2(Integer a, Integer b, Integer c, Integer d) {
String result = Stream.of(a, b, c, d).map(String::valueOf).collect(Collectors.joining(",")) + ",";
}
}
@@ -0,0 +1,6 @@
// "Fold expression into 'String.join'" "true"
class Test {
void test(String a, String b, String c, String d) {
String result = String.join(",", a, b, c, d) + ",";
}
}
@@ -0,0 +1,6 @@
// "Fold expression into Stream chain" "true"
class Test {
void test2(Integer a, Integer b, Integer c, Integer d) {
String result = a + "," + b + "," + c + "," <caret>+ d + ",";
}
}
@@ -0,0 +1,6 @@
// "Fold expression into 'String.join'" "true"
class Test {
void test(String a, String b, String c, String d) {
String result = a + "," + b + "," + c + ","<caret> + d + ",";
}
}