private static StringBuilder createNewLeafChars( final ASTNode leafElement, final TextRange textRange, final String whiteSpace) { final TextRange elementRange = leafElement.getTextRange(); final String elementText = leafElement.getText(); final StringBuilder result = new StringBuilder(); if (elementRange.getStartOffset() < textRange.getStartOffset()) { result.append( elementText.substring(0, textRange.getStartOffset() - elementRange.getStartOffset())); } result.append(whiteSpace); if (elementRange.getEndOffset() > textRange.getEndOffset()) { result.append( elementText.substring(textRange.getEndOffset() - elementRange.getStartOffset())); } return result; }
/** * Override to modify appended token text. For example: replace a trailing space with a newline. * Should append exact <code>lexer.getTokenEnd() - lexer.getTokenStart()</code> characters! */ protected StringBuilder appendCurrentTemplateToken( StringBuilder result, CharSequence buf, Lexer lexer) { return result.append(buf, lexer.getTokenStart(), lexer.getTokenEnd()); }