this.eventStore.revertMovedNodes();
return result;
}
private ASTNode getRootNode() {
ASTNode node= null;
int start= -1;
int end= -1;
for (Iterator iter= getRewriteEventStore().getChangeRootIterator(); iter.hasNext();) {
ASTNode curr= (ASTNode) iter.next();
if (!RewriteEventStore.isNewNode(curr)) {
int currStart= curr.getStartPosition();
int currEnd= currStart + curr.getLength();
if (node == null || currStart < start && currEnd > end) {
start= currStart;
end= currEnd;
node= curr;
} else if (currStart < start) {
start= currStart;
} else if (currEnd > end) {
end= currEnd;
}
}
}
if (node != null) {
int currStart= node.getStartPosition();
int currEnd= currStart + node.getLength();
while (start < currStart || end > currEnd) { // go up until a node covers all
node= node.getParent();
currStart= node.getStartPosition();
currEnd= currStart + node.getLength();
}
ASTNode parent= node.getParent(); // go up until a parent has different range
while (parent != null && parent.getStartPosition() == node.getStartPosition() && parent.getLength() == node.getLength()) {
node= parent;
parent= node.getParent();
}
}
return node;