protected void moveUp(
     ICompositeNode node, ICompositeNode previousNode, IModificationContext context)
     throws BadLocationException {
   IXtextDocument document = context.getXtextDocument();
   String text = node.getText() + previousNode.getText();
   text = text.trim();
   remove(document, node);
   document.replace(previousNode.getOffset(), previousNode.getLength(), text);
 }
 protected void remove(IXtextDocument document, ICompositeNode node) throws BadLocationException {
   int offset = node.getOffset();
   int length = node.getLength();
   if (node.hasPreviousSibling()) {
     INode previousSibling = node.getPreviousSibling();
     int endOffset = previousSibling.getEndOffset();
     length = length + (offset - endOffset);
     offset = endOffset;
   }
   document.replace(offset, length, "");
 }
 protected int[] getOffsetAndLength(XIfExpression ifExpression, ICompositeNode node) {
   int offset = node.getOffset();
   int length = node.getLength();
   if (ifExpression.getElse() != null) {
     ICompositeNode elseNode = NodeModelUtils.findActualNodeFor(ifExpression.getElse());
     if (elseNode != null) {
       length = elseNode.getOffset() - offset;
     }
   } else {
     XIfExpression parentIfExpression =
         EcoreUtil2.getContainerOfType(ifExpression.eContainer(), XIfExpression.class);
     if (parentIfExpression != null && parentIfExpression.getElse() == ifExpression) {
       ICompositeNode thenNode = NodeModelUtils.findActualNodeFor(parentIfExpression.getThen());
       if (thenNode != null) {
         int endOffset = thenNode.getEndOffset();
         length = length + (offset - endOffset);
         offset = endOffset;
       }
     }
   }
   return new int[] {offset, length};
 }
 private IRegion[] regionOf(Content content) {
   ICompositeNode node = NodeModelUtils.getNode(content);
   int length = node.getLength();
   int offset = node.getOffset();
   return new Region[] {new Region(offset, length)};
 }