boolean (@NotNull PsiMethod psiMethod, @NotNull PsiFile file, @NotNull Processor<? super PsiReference> consumer) { final Ref<Boolean> stopped = new Ref<>(false); file.accept(new XmlRecursiveElementVisitor() { @Override public void visitXmlElement(@NotNull XmlElement element) { if (stopped.get()) return; super.visitXmlElement(element); } @Override public void visitXmlAttribute(@NotNull XmlAttribute attribute) { if (stopped.get()) return; final PsiReference[] references = attribute.getReferences(); for (PsiReference reference : references) { if ((reference instanceof JavaFxStaticPropertyReference || reference instanceof JavaFxEventHandlerReference) && reference.isReferenceTo(psiMethod)) { if (!consumer.process(reference)) { stopped.set(true); return; } } } } }); return !stopped.get(); }