void (@NotNull final PsiElement element, @NotNull Processor<? super TextRange> consumer, @NotNull CharSequence text, final int cursorOffset, @NotNull Editor editor) { DumbService.getInstance(element.getProject()).withAlternativeResolveEnabled(() -> { PsiElement e = element; while (e != null && !(e instanceof PsiFile)) { if (processElement(e, consumer, text, cursorOffset, editor)) return; e = e.getParent(); } }); }