mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
DeclareCollectionAsInterfaceInspection: don't pass null to quick fix to avoid NPE
This commit is contained in:
+4
-12
@@ -92,7 +92,7 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection {
|
||||
|
||||
private final String typeString;
|
||||
|
||||
DeclareCollectionAsInterfaceFix(String typeString) {
|
||||
DeclareCollectionAsInterfaceFix(@NotNull String typeString) {
|
||||
this.typeString = typeString;
|
||||
}
|
||||
|
||||
@@ -215,17 +215,9 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection {
|
||||
final List<PsiClass> weaklingList = new ArrayList<>(weaklings);
|
||||
final PsiClass objectClass = javaLangObject.resolve();
|
||||
weaklingList.remove(objectClass);
|
||||
if (weaklingList.isEmpty()) {
|
||||
final String typeText = type.getCanonicalText();
|
||||
final String interfaceText = CollectionUtils.getInterfaceForClass(typeText);
|
||||
if (interfaceText == null) {
|
||||
return;
|
||||
}
|
||||
registerError(nameElement, interfaceText);
|
||||
}
|
||||
else {
|
||||
final PsiClass weakling = weaklingList.get(0);
|
||||
final String qualifiedName = weakling.getQualifiedName();
|
||||
String qualifiedName = weaklingList.isEmpty() ? CollectionUtils.getInterfaceForClass(type.getCanonicalText())
|
||||
: weaklingList.get(0).getQualifiedName();
|
||||
if (qualifiedName != null) {
|
||||
registerError(nameElement, qualifiedName);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -80,3 +80,11 @@ public class DeclareCollectionAsInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Labeling<T> {
|
||||
private Map<T, HashSet<Integer>> myLabels;
|
||||
|
||||
void addLabel(T node, HashSet<Integer> label){ // no warning on 'HashSet'
|
||||
myLabels.put<error descr="'put(T, java.util.HashSet<java.lang.Integer>)' in 'java.util.Map' cannot be applied to '(java.util.HashSet<java.lang.Integer>, T)'">(label, node)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user