String (@NotNull PsiPolyadicExpression expression) { StringBuilder content = new StringBuilder(); boolean isStringFound = false; boolean textBlock = useTextBlockTemplate(expression); for (PsiExpression operand : expression.getOperands()) { if (!isStringFound && ExpressionUtils.hasStringType(operand)) { isStringFound = true; if (!content.isEmpty()) { content.insert(0, "\\{").append("}"); } } if (operand instanceof PsiParenthesizedExpression parenthesized) { operand = PsiUtil.skipParenthesizedExprDown(parenthesized); } if (operand instanceof PsiLiteralExpression literal) { if (ExpressionUtils.hasStringType(literal)) { String value = (String)literal.getValue(); if (value == null) return null; // error in string literal String escaped = StringUtil.escapeStringCharacters(value); content.append(textBlock ? PsiLiteralUtil.escapeTextBlockCharacters(escaped, false, true, false) : escaped); } else { toTemplateExpression(content, isStringFound, literal); } } else { toTemplateExpression(content, isStringFound, operand); } } return textBlock ? "STR.\"\"\"\n" + content + "\"\"\"" : "STR.\"" + content + "\""; }