@Nullable
  public static Pair<PsiElement, PsiReference> getElementAndReference(@NotNull DataContext dataContext,
                                                                      @NotNull Project project,
                                                                      @Nullable PsiFile file,
                                                                      @Nullable Editor editor) {
    PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
    element = getElement(project, file, editor, element);

    if (element == null && file == null) return null;
    PsiFile containingFile = element != null ? element.getContainingFile() : file;
    if (containingFile == null || !containingFile.getViewProvider().isPhysical()) return null;


    PsiReference ref = null;
    if (editor != null) {
      ref = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
      if (element == null && ref != null) {
        element = TargetElementUtil.getInstance().adjustReference(ref);
      }
    }

    if (element != null) {
      //1. get element from sources if target is located in library class file
      //2. get original element if the element is synthetic (e.g. IDEA-224198)
      PsiElement navigationElement = element.getNavigationElement();
      if (navigationElement != null) {
        element = navigationElement;
      }
    }

    return Pair.pair(element, ref);
  }
@Nullable
  public static Pair<PsiElement, PsiReference> getElementAndReference(@NotNull DataContext dataContext,
                                                                      @NotNull Project project,
                                                                      @Nullable PsiFile file,
                                                                      @Nullable Editor editor)