String () { StringBuilder builder = new StringBuilder(); boolean hasText = false; final PsiType formatType = myExpression.getType(); if (formatType == null || !formatType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { return null; } PsiExpression psiExpression = myExpression; if (myExpression instanceof PsiLocalVariable variable) { if (VariableAccessUtils.variableIsAssigned(variable)) { return null; } psiExpression = variable.getInitializer(); } if (psiExpression instanceof PsiPolyadicExpression polyadicExpression) { PsiExpression[] operands = polyadicExpression.getOperands(); for (int i = 0, length = operands.length; i < length; i++) { PsiExpression operand = operands[i]; String stringPart = (String)ConstantExpressionUtil.computeCastTo(operand, formatType); if (stringPart != null) { if (i == 0) { hasText = true; } builder.append(stringPart); } else { return hasText ? builder.toString() : null; } } } return builder.toString(); }