Object (PsiExpression key) { if (key == null) return null; key = PsiUtil.skipParenthesizedExprDown(key); Object constant = ExpressionUtils.computeConstantExpression(key); if (constant != null) { return constant; } if (key instanceof PsiReferenceExpression) { PsiVariable var = tryCast(((PsiReferenceExpression)key).resolve(), PsiVariable.class); if (var instanceof PsiEnumConstant) return var; if (var != null) { if (var.hasModifierProperty(PsiModifier.FINAL) && (var.hasModifierProperty(PsiModifier.STATIC) || ExpressionUtil.isEffectivelyUnqualified((PsiReferenceExpression)key))) { return var; } if (PsiUtil.isJvmLocalVariable(var)) { PsiElement scope = PsiUtil.getVariableCodeBlock(var, null); if (scope != null && HighlightControlFlowUtil.isEffectivelyFinal(var, scope, null)) { return var; } } } } return null; }