private static @Nullable PsiElement doGetReferenceOrReferencedElement(@NotNull Editor editor, int flags, int offset) {
    PsiReference ref = findReference(editor, offset);
    if (ref == null) return null;

    Project project = editor.getProject();
    if (project == null) return null;
    return getReferencedElement(ref, flags);
  }
private static @Nullable PsiElement doGetReferenceOrReferencedElement(@NotNull Editor editor, int flags, int offset)