String (@NotNull PsiExpression expression, int maxLength) { StringBuilder buf = new StringBuilder(); expression.accept(new PsiExpressionTrimRenderer(buf)); final String text = buf.toString(); int firstNewLinePos = text.indexOf('\n'); String trimmedText = text.substring(0, firstNewLinePos != -1 ? firstNewLinePos : Math.min(maxLength, text.length())); if (trimmedText.length() != text.length()) trimmedText += " ..."; return trimmedText; }