PsiExpression (@NotNull PsiReferenceExpression ref) { PsiExpression qualifier = ref.getQualifierExpression(); if (qualifier != null) return qualifier; PsiMember member = tryCast(ref.resolve(), PsiMember.class); if (member == null) { // Reference resolves to non-member: probably variable/parameter/etc. return null; } return getEffectiveQualifier(ref, member); }