boolean (@NotNull PsiReferenceExpression expression, @NotNull PsiField referencedField, @NotNull PsiClass containingClass) { PsiExpression qualifierExpr = expression.getQualifierExpression(); // simple reference can be illegal (JLS 8.3.3) if (qualifierExpr == null) return false; if (!(qualifierExpr instanceof PsiReferenceExpression)) return true; PsiElement qualifiedReference = ((PsiReferenceExpression)qualifierExpr).resolve(); if (containingClass.equals(qualifiedReference)) { // static fields that are constant variables (4.12.4) are initialized before other static fields (12.4.2), // so a qualified reference to the constant variable is possible. return PsiUtil.isCompileTimeConstant(referencedField); } return true; }