public static @Nullable PsiReference findReference(@NotNull Editor editor, int offset) {
    Project project = editor.getProject();
    if (project == null) return null;

    Document document = editor.getDocument();
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (file == null) return null;

    PsiReference ref = file.findReferenceAt(adjustOffset(file, document, offset));
    if (ref == null) return null;
    int elementOffset = ref.getElement().getTextRange().getStartOffset();

    for (TextRange range : ReferenceRange.getRanges(ref)) {
      if (range.shiftRight(elementOffset).containsOffset(offset)) {
        return ref;
      }
    }

    return null;
  }
public static @Nullable PsiReference findReference(@NotNull Editor editor, int offset)