private static @Nullable PsiElement getMember(PsiElement element) {
    if (element instanceof PsiMember) return element;

    if (element instanceof PsiReference) {
      PsiElement resolved = ((PsiReference)element).resolve();
      if (resolved instanceof PsiMember) return resolved;
    }

    if (!(element instanceof PsiIdentifier)) return null;

    PsiElement parent = element.getParent();
    PsiMember member = null;
    if (parent instanceof PsiJavaCodeReferenceElement) {
      PsiElement resolved = ((PsiJavaCodeReferenceElement)parent).resolve();
      if (resolved instanceof PsiMember) {
        member = (PsiMember)resolved;
      }
    }
    else if (parent instanceof PsiMember) {
      member = (PsiMember)parent;
    }
    return member;
  }
private static @Nullable PsiElement getMember(PsiElement element)