String (@NotNull String text, int offset, boolean escapeStartQuote, boolean escapeEndQuote) { StringBuilder buffer = new StringBuilder(text.length()); final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, false); String indent = " ".repeat(offset); for (int i = 0; i < lines.length; i++) { String content = PsiLiteralUtil.escapeBackSlashesInTextBlock(lines[i]); content = PsiLiteralUtil.escapeTextBlockCharacters(content, i == 0 && escapeStartQuote, i == lines.length - 1 && escapeEndQuote, true); buffer.append(content); if (i < lines.length - 1) { buffer.append('\n').append(indent); } } return buffer.toString(); }