List<PsiElement> (@NotNull PsiMethod method) { if (IntentionPreviewUtils.isIntentionPreviewActive()) { return SyntaxTraverser.psiTraverser(method.getContainingFile()) .filter(ref -> ref instanceof PsiJavaCodeReferenceElement && ((PsiJavaCodeReferenceElement)ref).isReferenceTo(method) || ref instanceof PsiEnumConstant && method.isEquivalentTo(((PsiEnumConstant)ref).resolveMethod())) .toList(); } final Collection<PsiReference> references = ReferencesSearch.search(method).findAll(); final List<PsiElement> refElements = new ArrayList<>(); for (PsiReference reference : references) { refElements.add(reference.getElement()); } return refElements; }