private static @NotNull <T extends PsiElement> SmartPsiElementPointer<T> createElementRef(@NotNull T element, @NotNull TextRange range) {
    PsiFile containingFile = element.getContainingFile();
    Project project = containingFile.getProject();
    TextRange topLevelRange = InjectedLanguageManager.getInstance(project).getTopLevelFile(containingFile).getTextRange();
    if (!topLevelRange.contains(range)) {
      throw new IllegalArgumentException("Range must be inside file offsets "+topLevelRange+" but got: "+range);
    }
    PsiElement firstChild;
    if (!(element instanceof PsiFile) && (firstChild = element.getFirstChild()) != null) {
      String msg = "Performance warning: LineMarker is supposed to be registered for leaf elements only, but got: " +
                   element + " (" + element.getClass() + ") instead. First child: " +
                   firstChild + " (" + firstChild.getClass() + ")" +
                   "\nPlease see LineMarkerProvider#getLineMarkerInfo(PsiElement) javadoc for detailed explanations.";
      if (ApplicationManager.getApplication().isUnitTestMode()) {
        LOG.error(msg);
      }
      else {
        LOG.warn(msg);
      }
    }
    return SmartPointerManager.getInstance(project).createSmartPsiElementPointer(element, containingFile);
  }
private static @NotNull <T extends PsiElement> SmartPsiElementPointer<T> createElementRef(@NotNull T element, @NotNull TextRange range)