IDEA-180417 Generated code ("Replace with collect") is invalid follow-up

Fixed for groupingBy as well
This commit is contained in:
Tagir Valeev
2017-10-13 13:12:17 +07:00
parent 59c3fd672a
commit 14759e531a
3 changed files with 29 additions and 1 deletions
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
public void test() {
String[] values = {"a", "b", "c"};
Map<String, List<Object>> map = IntStream.range(0, values.length).boxed().collect(Collectors.groupingBy(i -> "X" + i, Collectors.mapping(i -> values[i], Collectors.toList())));
}
}
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
public void test() {
String[] values = {"a", "b", "c"};
Map<String, List<Object>> map = new HashMap<>();
f<caret>or (int i = 0; i < values.length; i++) {
map.computeIfAbsent("X" + i, k -> new ArrayList<>()).add(values[i]);
}
}
}