List<UsageInfo> (PsiMember member, GroovyFileBase file) { LocalSearchScope scope = new LocalSearchScope(file); final ArrayList<UsageInfo> infos = new ArrayList<>(); final HashSet<Object> usedRefs = new HashSet<>(); final Processor<PsiReference> consumer = reference -> { if (usedRefs.add(reference)) { infos.add(new UsageInfo(reference)); } return true; }; if (member instanceof PsiMethod) { MethodReferencesSearch.search((PsiMethod)member, scope, false).forEach(consumer); } else { ReferencesSearch.search(member, scope).forEach(consumer); if (member instanceof PsiField) { final PsiMethod getter = GroovyPropertyUtils.findGetterForField((PsiField)member); if (getter != null) { MethodReferencesSearch.search(getter, scope, false).forEach(consumer); } final PsiMethod setter = GroovyPropertyUtils.findSetterForField((PsiField)member); if (setter != null) { MethodReferencesSearch.search(setter, scope, false).forEach(consumer); } } } return infos; }