@Nullable
  public static SourcePosition createFromElement(@NotNull PsiElement element) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    PsiElement navigationElement = element.getNavigationElement();
    final SmartPsiElementPointer<PsiElement> pointer =
      SmartPointerManager.getInstance(navigationElement.getProject()).createSmartPsiElementPointer(navigationElement);
    final PsiFile psiFile;
    if (JspPsiUtil.isInJspFile(navigationElement)) {
      psiFile = JspPsiUtil.getJspFile(navigationElement);
    }
    else {
      psiFile = navigationElement.getContainingFile();
    }
    if (psiFile == null) return null;
    return new SourcePositionCache(psiFile) {
      @Override
      protected PsiElement calcPsiElement() {
        return pointer.getElement();
      }

      @Override
      protected int calcOffset() {
        return ReadAction.compute(() -> {
          PsiElement elem = pointer.getElement();
          return elem != null ? elem.getTextOffset() : -1;
        });
      }
    };
  }
@Nullable
  public static SourcePosition createFromElement(@NotNull PsiElement element)