Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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, "");
 }
Exemplo n.º 3
0
 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};
 }
 protected void highlightAnnotation(
     XAnnotation annotation,
     IHighlightedPositionAcceptor acceptor,
     String highlightingConfiguration) {
   JvmType annotationType = annotation.getAnnotationType();
   if (annotationType != null
       && !annotationType.eIsProxy()
       && annotationType instanceof JvmAnnotationType) {
     ICompositeNode xannotationNode = NodeModelUtils.findActualNodeFor(annotation);
     if (xannotationNode != null) {
       ILeafNode firstLeafNode =
           NodeModelUtils.findLeafNodeAtOffset(xannotationNode, xannotationNode.getOffset());
       if (firstLeafNode != null)
         highlightNode(acceptor, firstLeafNode, highlightingConfiguration);
     }
     highlightReferenceJvmType(
         acceptor,
         annotation,
         XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE,
         annotationType,
         highlightingConfiguration);
   }
 }
 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)};
 }