void preRemoveChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
   if (property.isChildProperty()) {
     NodeRewriteEvent event = getNodeEvent(node, property);
     event.setNewValue(null);
   } else if (property.isChildListProperty()) {
     ListRewriteEvent event = getListEvent(node, property);
     int i = event.getIndex(child, ListRewriteEvent.NEW);
     NodeRewriteEvent nodeEvent = (NodeRewriteEvent) event.getChildren()[i];
     if (nodeEvent.getOriginalValue() == null) {
       event.revertChange(nodeEvent);
     } else {
       nodeEvent.setNewValue(null);
     }
   }
 }
 void preReplaceChildEvent(
     ASTNode node, ASTNode child, ASTNode newChild, StructuralPropertyDescriptor property) {
   if (property.isChildProperty()) {
     NodeRewriteEvent event = getNodeEvent(node, property);
     event.setNewValue(newChild);
     if (newChild != null) {
       markAsMoveOrCopyTarget(node, newChild);
     }
   } else if (property.isChildListProperty()) {
     ListRewriteEvent event = getListEvent(node, property);
     int i = event.getIndex(child, ListRewriteEvent.NEW);
     NodeRewriteEvent nodeEvent = (NodeRewriteEvent) event.getChildren()[i];
     nodeEvent.setNewValue(newChild);
     if (newChild != null) {
       markAsMoveOrCopyTarget(node, newChild);
     }
   }
 }
  void postAddChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
    if (property.isChildListProperty()) {

      ListRewriteEvent event = getListEvent(node, property);
      List list = (List) node.getStructuralProperty(property);
      int i = list.indexOf(child);
      int s = list.size();
      int index;
      if (i + 1 < s) {
        ASTNode nextNode = (ASTNode) list.get(i + 1);
        index = event.getIndex(nextNode, ListRewriteEvent.NEW);
      } else {
        index = -1;
      }
      event.insert(child, index);
      if (child != null) {
        markAsMoveOrCopyTarget(node, child);
      }
    }
  }