@Override public Object computeConstantValue(Set<PsiVariable> visitedVars) { if (!hasModifierProperty(PsiModifier.FINAL)) return null; PsiType type = getType(); // javac rejects all non primitive and non String constants, although JLS states constants "variables whose initializers are constant expressions" if (!(type instanceof PsiPrimitiveType) && !type.equalsToText("java.lang.String")) return null; PsiExpression initializer = getInitializer(); if (initializer == null) return null; return PsiConstantEvaluationHelperImpl.computeCastTo(initializer, getType(), visitedVars); }
@Nullable private Object _computeConstantValue(Set<PsiVariable> visitedVars) { PsiType type = getType(); // javac rejects all non primitive and non String constants, although JLS states constants "variables whose initializers are constant expressions" if(!(type instanceof PsiPrimitiveType) && !type.equalsToText("java.lang.String")) { return null; } PsiExpression initializer = getDetachedInitializer(); return PsiConstantEvaluationHelperImpl.computeCastTo(initializer, type, visitedVars); }