void (@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); final PsiElement qualifier = expression.getQualifier(); if (!(qualifier instanceof PsiReferenceExpression)) { return; } final PsiElement referent = expression.resolve(); if (!(referent instanceof PsiField field)) { return; } if (!field.hasModifierProperty(PsiModifier.STATIC)) { return; } final PsiElement qualifierReferent = ((PsiReferenceExpression)qualifier).resolve(); if (!(qualifierReferent instanceof PsiClass referencedClass)) { return; } final PsiClass declaringClass = field.getContainingClass(); if (declaringClass == null || declaringClass.equals(referencedClass)) { return; } final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper(); if (!resolveHelper.isAccessible(declaringClass, expression, null)) { return; } final PsiElement identifier = expression.getReferenceNameElement(); if (identifier == null) { return; } registerError(identifier, declaringClass, referencedClass); }