void (@NotNull ASTNode parent, @NotNull ASTNode first, @NotNull ASTNode last) { boolean tailingElement = last.getStartOffset() + last.getTextLength() == parent.getStartOffset() + parent.getTextLength(); boolean forceReformat = needToForceReformat(parent, first, last); saveWhitespacesInfo(first); TreeElement child = (TreeElement)first; while (child != null) { //checkForOuters(child); if (child == last) break; child = child.getTreeNext(); } assert child == last : last + " is not a successor of " + first + " in the .getTreeNext() chain"; ASTNode prevLeaf = TreeUtil.prevLeaf(first); ASTNode nextLeaf = TreeUtil.nextLeaf(last); parent.removeRange(first, last.getTreeNext()); ASTNode nextLeafToAdjust = nextLeaf; if (nextLeafToAdjust != null && prevLeaf != null && nextLeafToAdjust.getTreeParent() == null) { //next element has invalidated nextLeafToAdjust = prevLeaf.getTreeNext(); } makePlaceHolderBetweenTokens(prevLeaf, nextLeafToAdjust, forceReformat, tailingElement); }