String (IElementType tokenType, String content, int indent) { final StringBuilder result = new StringBuilder(); int strip = (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN) ? 0 : -1; for (int i = 0, length = content.length(); i < length; i++) { final char c = content.charAt(i); if (strip >= 0) { if (c == '\n') { strip = -1; } else if (strip <= indent) { strip++; } } if (c == '\n') { while (result.length() > 0) { int end = result.length() - 1; char d = result.charAt(end); if (d == '\n' || !Character.isWhitespace(d)) break; // trim line trailing whitespace result.deleteCharAt(end); } strip = 0; } else if (strip > indent && indent > 0) { // strip indent int end = result.length(); result.delete(end - indent, end); strip = -1; } result.append(c); } return result.toString(); }