boolean (PsiElement element, PsiType qualifierType, PsiType expectedType, LookupElement item) { Object object = item.getObject(); if (object instanceof PsiModifierListOwner && ((PsiModifierListOwner)object).hasModifierProperty(PsiModifier.STATIC)) { return false; } if (object instanceof PsiMethod method) { if (psiMethod().withName("toArray").withParameterCount(1) .definedInClass(CommonClassNames.JAVA_UTIL_COLLECTION).accepts(method)) { return false; } final PsiMethod parentMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class); if (isUselessObjectMethod(method, parentMethod, qualifierType)) { return false; } final PsiType type = method.getReturnType(); if (type instanceof PsiClassType classType) { final PsiClass psiClass = classType.resolve(); if (psiClass instanceof PsiTypeParameter typeParameter && method.getTypeParameterList() == psiClass.getParent()) { if (typeParameter.getExtendsListTypes().length == 0) return false; if (!expectedType.isAssignableFrom(TypeConversionUtil.typeParameterErasure(typeParameter))) return false; } } } return true; }