IDEA-178788 Suggestion code replace from list iteration to List.removeAll

This commit is contained in:
Tagir Valeev
2017-09-13 09:41:13 +07:00
parent 89bc22ddf7
commit 35eb29010f
7 changed files with 25 additions and 47 deletions
@@ -26,8 +26,7 @@ import java.util.stream.Stream;
*/
public class JdkBulkMethodInfoProvider implements BulkMethodInfoProvider {
private static BulkMethodInfo[] INFOS = {
new BulkMethodInfo(CommonClassNames.JAVA_UTIL_COLLECTION, "add", "addAll"),
new BulkMethodInfo(CommonClassNames.JAVA_UTIL_LIST, "remove", "removeAll")
new BulkMethodInfo(CommonClassNames.JAVA_UTIL_COLLECTION, "add", "addAll")
};
@NotNull
@@ -0,0 +1,10 @@
// "Replace iteration with bulk 'Collection.addAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toAdd){
persons.addAll(toAdd);
}
}
@@ -1,10 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
persons.removeAll(toRemove);
}
}
@@ -1,10 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
persons.removeAll(toRemove);
}
}
@@ -0,0 +1,14 @@
// "Replace iteration with bulk 'Collection.addAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toAdd){
Iterator<Person> it = toAdd.iterator();
while (it.hasNext()) {
Person person = it.next();
persons<caret>.add(person);
}
}
}
@@ -1,11 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
for (Iterator<Person> it = toRemove.iterator(); it.hasNext(); )
persons<caret>.remove(it.next());
}
}
@@ -1,14 +0,0 @@
// "Replace iteration with bulk 'List.removeAll' call" "true"
import java.util.*;
public class Collect {
static class Person {}
void collectNames(List<Person> persons, Collection<Person> toRemove){
Iterator<Person> it = toRemove.iterator();
while (it.hasNext()) {
Person person = it.next();
persons<caret>.remove(person);
}
}
}