public static void processRanges(@Nullable PsiElement element,
                                   @NotNull CharSequence text,
                                   int cursorOffset,
                                   @NotNull Editor editor,
                                   @NotNull Processor<? super TextRange> consumer) {
    if (element == null) return;

    PsiFile file = element.getContainingFile();

    FileViewProvider viewProvider = file.getViewProvider();

    processInFile(element, consumer, text, cursorOffset, editor);

    for (PsiFile psiFile : viewProvider.getAllFiles()) {
      if (psiFile == file) continue;

      FileASTNode fileNode = psiFile.getNode();
      if (fileNode == null) continue;

      ASTNode nodeAt = fileNode.findLeafElementAt(element.getTextOffset());
      if (nodeAt == null) continue;

      PsiElement elementAt = nodeAt.getPsi();

      while (!(elementAt instanceof PsiFile) && elementAt != null) {
        if (elementAt.getTextRange().contains(element.getTextRange())) break;

        elementAt = elementAt.getParent();
      }

      if (elementAt == null) continue;

      processInFile(elementAt, consumer, text, cursorOffset, editor);
    }
  }
public static void processRanges(@Nullable PsiElement element,
                                   @NotNull CharSequence text,
                                   int cursorOffset,
                                   @NotNull Editor editor,
                                   @NotNull Processor<? super TextRange> consumer)