public static @Nullable SnippetRenderingData calculateSnippetRenderingData(@NotNull PsiElement element,
                                                                             @Nullable ProperTextRange infoRange) {
    PsiDocumentManager docManager = PsiDocumentManager.getInstance(element.getProject());
    Document doc = docManager.getDocument(InjectedLanguageManager.getInstance(element.getProject()).getTopLevelFile(element));
    if (doc == null) return null;
    TextRange selectionRange = UsagePreviewPanel.calculateHighlightingRangeForUsage(element, infoRange);
    if (element instanceof PsiNamedElement && !(element instanceof PsiFile)) {
      selectionRange = UsagePreviewPanel.getNameElementTextRange(element);
    }
    selectionRange = InjectedLanguageManager.getInstance(element.getProject()).injectedToHost(element, selectionRange);
    int usageStartLineNumber = doc.getLineNumber(selectionRange.getStartOffset());
    int usageEndLineNumber = doc.getLineNumber(selectionRange.getEndOffset());
    final int contextStartLineNumber = Math.max(0, usageStartLineNumber - CONTEXT_LINE_NUMBER);
    int startOffset = doc.getLineStartOffset(contextStartLineNumber);
    int endOffset = doc.getLineEndOffset(Math.min(usageEndLineNumber + CONTEXT_LINE_NUMBER, doc.getLineCount() - 1));
    selectionRange = selectionRange.shiftLeft(startOffset);
    String text = doc.getText(new TextRange(startOffset, endOffset));
    LineNumberConverter converter = contextStartLineNumber == 0 ? LineNumberConverter.DEFAULT : new LineNumberConverter.Increasing() {
      @Override
      public Integer convert(@NotNull Editor editor, int lineNumber) {
        return lineNumber + contextStartLineNumber;
      }
    };
    return new SnippetRenderingData(element.getProject(), element.getLanguage(), selectionRange, text, converter);
  }
public static @Nullable SnippetRenderingData calculateSnippetRenderingData(@NotNull PsiElement element,
                                                                             @Nullable ProperTextRange infoRange)