void (@NotNull PsiField field) { if (field.hasModifierProperty(PsiModifier.STATIC)) { return; } if (!field.hasModifierProperty(PsiModifier.FINAL)) { return; } final PsiExpression initializer = field.getInitializer(); if (initializer == null) { return; } if (SideEffectChecker.mayHaveSideEffects(initializer)) { return; } final PsiType type = field.getType(); if (!ClassUtils.isImmutable(type) && Mutability.fromDfType(CommonDataflow.getDfType(initializer)) != Mutability.UNMODIFIABLE) { return; } final PsiClass containingClass = field.getContainingClass(); if (containingClass != null && !containingClass.hasModifierProperty(PsiModifier.STATIC) && containingClass.getContainingClass() != null && !HighlightingFeature.INNER_STATICS.isAvailable(containingClass) && !PsiUtil.isCompileTimeConstant(field)) { // inner class cannot have static declarations in earlier Java versions return; } if (UnusedSymbolUtil.isImplicitWrite(field)) { return; } if (containingClass instanceof PsiAnonymousClass && !HighlightingFeature.INNER_STATICS.isAvailable(containingClass) && !PsiUtil.isCompileTimeConstant(field)) { return; } if (!canBeStatic(initializer)) { return; } if (isIdentitySensitive(field)) { return; } registerFieldError(field); }