List<TextRange> (@NotNull Project project, @NotNull CharSequence text, @NotNull Language language) { return ReadAction.compute(() -> { List<TextRange> result = new ArrayList<>(); PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("", language, text); psiFile.accept(new PsiElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element.getTextLength() == 0) return; if (isIgnored(element)) { result.add(element.getTextRange()); } else { element.acceptChildren(this); } } }); return result; }); }