String (@NotNull PsiElement element) { if (element instanceof PsiLiteralExpression) { Object value = ((PsiLiteralExpression)element).getValue(); if (value instanceof String) { return (String)value; } } else if (element instanceof PsiReferenceExpression) { PsiElement psiElement = ((PsiReferenceExpression)element).resolve(); if (psiElement instanceof PsiVariableEx) { Object val = ((PsiVariableEx)psiElement).computeConstantValue(new HashSet<>()); if (val instanceof String) { return (String)val; } } } return null; }