void (StringBuilder methodCall, StringBuilder logText, boolean isStringBlock, int indent) { if (!isStringBlock) { methodCall.append('"') .append(StringUtil.escapeStringCharacters(logText.toString())) .append('"'); logText.delete(0, logText.length()); return; } String delimiters = "\n" + " ".repeat(indent); String preparedText = StreamEx.of(logText.toString().split("\n", -1)) .map(line -> line.endsWith(" ") ? line.substring(0, line.length() - 1) + "\\s" : line) .joining(delimiters, delimiters, ""); preparedText = PsiLiteralUtil.escapeTextBlockCharacters(preparedText, true, true, false); methodCall.append("\"\"\"") .append(preparedText) .append("\"\"\""); logText.delete(0, logText.length()); }