mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
foreach -> collect: simplify to addAll on collections if no filter/mapper is present (IDEA-150515)
This commit is contained in:
+2
-3
@@ -1,13 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
// "Replace with addAll" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
String foo(){
|
||||
Sample sm = new Sample();
|
||||
sm.foo.addAll(foo.stream().collect(Collectors.toList()));
|
||||
sm.foo.addAll(foo);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
// "Replace with addAll" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Collect {
|
||||
class Person {}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<Person> names = persons.stream().collect(Collectors.toList());
|
||||
List<Person> names = new ArrayList<>();
|
||||
names.addAll(persons);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace with collect" "true"
|
||||
// "Replace with addAll" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace with collect" "true"
|
||||
// "Replace with addAll" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Collect {
|
||||
|
||||
Reference in New Issue
Block a user