String (@NotNull PsiExpression expression) { Object constantExpression = ExpressionUtils.computeConstantExpression(expression); if (constantExpression != null) { return String.valueOf(constantExpression); } else { PsiLocalVariable variable = resolveLocalVariable(expression); if(variable == null) return null; PsiElement parent = variable.getParent(); PsiExpression initializer = variable.getInitializer(); if(parent == null || initializer == null) return null; if(!isEffectivelyFinal(variable, parent, null)) return null; Object initializerConstant = ExpressionUtils.computeConstantExpression(initializer); if(initializerConstant == null) return null; return String.valueOf(initializerConstant); } }