boolean (final PsiMethod method, final PsiTypeParameter typeParameter) { final String typeParameterName = typeParameter.getName(); final PsiTypeVisitor<Boolean> visitor = new PsiTypeVisitor<>() { @Override public Boolean visitClassType(@NotNull PsiClassType classType) { final PsiClass psiClass = classType.resolve(); if (psiClass instanceof PsiTypeParameter && PsiTreeUtil.isAncestor(((PsiTypeParameter)psiClass).getOwner(), method, true)) { return false; } if (Comparing.strEqual(typeParameterName, classType.getCanonicalText())) { return true; } for (PsiType p : classType.getParameters()) { if (p.accept(this)) return true; } return false; } @Override public Boolean visitPrimitiveType(@NotNull PsiPrimitiveType primitiveType) { return false; } @Override public Boolean visitArrayType(@NotNull PsiArrayType arrayType) { return arrayType.getComponentType().accept(this); } @Override public Boolean visitWildcardType(@NotNull PsiWildcardType wildcardType) { final PsiType bound = wildcardType.getBound(); if (bound != null) { return bound.accept(this); } return false; } }; final PsiTypeElement rElement = method.getReturnTypeElement(); if (rElement != null) { if (rElement.getType().accept(visitor)) return true; } for (PsiParameter parameter : method.getParameterList().getParameters()) { final PsiTypeElement element = parameter.getTypeElement(); if (element != null) { if (element.getType().accept(visitor)) return true; } } return false; }