IDEA-163082 "can be replaced with addAll" inspection suggests a recursive call; support "this" qualifier for collect/addAll conversion

This commit is contained in:
Tagir Valeev
2016-10-25 11:38:24 +07:00
parent 4ce59ee865
commit 6e3d0c6c0e
4 changed files with 79 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
// "Replace with addAll" "true"
import java.util.*;
public class Main {
static class MyList extends AbstractCollection<String> {
@Override
public Iterator<String> iterator() {
return Collections.emptyIterator();
}
@Override
public int size() {
return 0;
}
public boolean myAdd(Collection<? extends String> c) {
this.addAll(c);
return true;
}
}
}

View File

@@ -0,0 +1,25 @@
// "Replace with addAll" "false"
import java.util.*;
public class Main {
static class MyList extends AbstractCollection<String> {
@Override
public Iterator<String> iterator() {
return Collections.emptyIterator();
}
@Override
public int size() {
return 0;
}
@Override
public boolean addAll(Collection<? extends String> c) {
for (String e : <caret>c) {
add(e);
}
return true;
}
}
}

View File

@@ -0,0 +1,24 @@
// "Replace with addAll" "true"
import java.util.*;
public class Main {
static class MyList extends AbstractCollection<String> {
@Override
public Iterator<String> iterator() {
return Collections.emptyIterator();
}
@Override
public int size() {
return 0;
}
public boolean myAdd(Collection<? extends String> c) {
for (String e : <caret>c) {
this.add(e);
}
return true;
}
}
}