void (final ASTNode astNode, final String whiteSpace, final TextRange textRange) { ASTNode lastWS = TreeUtil.findLastLeaf(astNode); if (lastWS == null) { return; } if (lastWS.getElementType() != TokenType.WHITE_SPACE) { lastWS = null; } if (lastWS != null && !lastWS.getTextRange().equals(textRange)) { return; } if (whiteSpace.isEmpty() && lastWS == null) { return; } if (lastWS != null && whiteSpace.isEmpty()) { lastWS.getTreeParent().removeRange(lastWS, null); return; } LeafElement whiteSpaceElement = ASTFactory.whitespace(whiteSpace); if (lastWS == null) { astNode.addChild(whiteSpaceElement, null); } else { ASTNode treeParent = lastWS.getTreeParent(); treeParent.replaceChild(lastWS, whiteSpaceElement); } }