mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MismatchedCollectionQueryUpdate: tuning default method names, more tests
This commit is contained in:
+4
-4
@@ -57,8 +57,8 @@ public class MismatchedCollectionQueryUpdateInspectionBase extends BaseInspectio
|
||||
|
||||
private static final CallMatcher COLLECTION_SAFE_ARGUMENT_METHODS =
|
||||
CallMatcher.anyOf(
|
||||
CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_COLLECTION, "addAll", "removeAll", "containsAll"),
|
||||
CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_MAP, "putAll")
|
||||
CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_COLLECTION, "addAll", "removeAll", "containsAll", "remove"),
|
||||
CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_MAP, "putAll", "remove")
|
||||
);
|
||||
|
||||
private static final Set<String> COLLECTIONS_QUERIES =
|
||||
@@ -72,8 +72,8 @@ public class MismatchedCollectionQueryUpdateInspectionBase extends BaseInspectio
|
||||
@SuppressWarnings("PublicField")
|
||||
public final ExternalizableStringSet queryNames =
|
||||
new ExternalizableStringSet(
|
||||
"contains", "copyInto", "equals", "forEach", "get", "hashCode", "parallelStream", "propertyNames", "replaceAll", "save",
|
||||
"size", "store", "stream", "toArray", "toString", "write");
|
||||
"contains", "copyInto", "equals", "forEach", "get", "hashCode", "iterator", "parallelStream", "propertyNames",
|
||||
"replaceAll", "save", "size", "store", "stream", "toArray", "toString", "write");
|
||||
@SuppressWarnings("PublicField")
|
||||
public final ExternalizableStringSet updateNames =
|
||||
new ExternalizableStringSet("add", "clear", "insert", "load", "merge", "offer", "poll", "pop", "push", "put", "remove", "replace",
|
||||
|
||||
+27
@@ -84,6 +84,13 @@ public class MismatchedCollectionQueryUpdate {
|
||||
return l.toArray();
|
||||
}
|
||||
|
||||
Object[] testRemoveFromAnotherCollection(List<List<String>> list) {
|
||||
List<String> <warning descr="Contents of collection 'l' are queried, but never updated">l</warning> = new ArrayList<>();
|
||||
list.remove(l);
|
||||
process(list);
|
||||
return l.toArray();
|
||||
}
|
||||
|
||||
native void process(List<List<String>> list);
|
||||
|
||||
void testPureMethod() {
|
||||
@@ -147,6 +154,26 @@ public class MismatchedCollectionQueryUpdate {
|
||||
nonInitialized.add(key);
|
||||
}
|
||||
|
||||
void testListIterator() {
|
||||
// IDEA-128168
|
||||
List<String> test = new ArrayList<String>();
|
||||
ListIterator<String> i = test.listIterator(0);
|
||||
i.add("hello!");
|
||||
System.out.println(i.next());
|
||||
}
|
||||
|
||||
void testIterator() {
|
||||
List<String> <warning descr="Contents of collection 'test' are queried, but never updated">test</warning> = new ArrayList<String>();
|
||||
Iterator<String> i = test.iterator();
|
||||
while(i.hasNext()) {
|
||||
if(i.next() == null) {
|
||||
// Normally iterator cannot add, remove only. If collection is always empty (not updated in any other way),
|
||||
// this is useless anyways
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Node{
|
||||
private SortedSet mChildren;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user