StringBuilder (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, 0, textRange.getStartOffset() - elementRange.getStartOffset()); } result.append(whiteSpace); if (elementRange.getEndOffset() > textRange.getEndOffset()) { result.append(elementText.substring(textRange.getEndOffset() - elementRange.getStartOffset())); } return result; }