@ApiStatus.Internal
  @RequiresReadLock
  public static <RESULT> RESULT visit(@NotNull XSourcePosition position,
                                      @NotNull Project project,
                                      @Nullable RESULT defaultResult,
                                      @NotNull Visitor<? extends RESULT> visitor) {
    Document document = FileDocumentManager.getInstance().getDocument(position.getFile());
    PsiFile file = document == null || document.getTextLength() == 0 ? null : PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (file == null) {
      return defaultResult;
    }

    int positionOffset;
    int column = position instanceof SourceInfo ? Math.max(((SourceInfo)position).getColumn(), 0) : 0;
    try {
      positionOffset = column == 0 ? DocumentUtil.getFirstNonSpaceCharOffset(document, position.getLine()) : document.getLineStartOffset(position.getLine()) + column;
    }
    catch (IndexOutOfBoundsException ignored) {
      return defaultResult;
    }

    PsiElement element = file.findElementAt(positionOffset);
    return element == null ? defaultResult : visitor.visit(position, element, positionOffset, document);
  }
@ApiStatus.Internal
  @RequiresReadLock
  public static <RESULT> RESULT visit(@NotNull XSourcePosition position,
                                      @NotNull Project project,
                                      @Nullable RESULT defaultResult,
                                      @NotNull Visitor<? extends RESULT> visitor)