boolean (final Processor<? super PsiReference> processor, final PsiFile file, String name, final PsiElement element, final LocalSearchScope filterScope) { CharSequence chars = ApplicationManager.getApplication().runReadAction((NullableComputable<CharSequence>)() -> { if (filterScope != null) { boolean isInScope = false; for(PsiElement filterElement: filterScope.getScope()) { if (PsiTreeUtil.isAncestor(filterElement, file, false)) { isInScope = true; break; } } if (!isInScope) return null; } return file.getViewProvider().getContents(); }); if (chars == null) return true; int index = 0; final int offset = name.lastIndexOf('.'); while(true){ index = CharArrayUtil.indexOf(chars, name, index); if (index < 0) break; final int finalIndex = index; final Boolean searchDone = ApplicationManager.getApplication().runReadAction((NullableComputable<Boolean>)() -> { final PsiReference ref = file.findReferenceAt(finalIndex + offset + 1); if (ref != null && ref.isReferenceTo(element)) { return processor.process(ref); } return true; }); if (!searchDone.booleanValue()) return false; index++; } return true; }