Package org.eclipse.xtext.nodemodel

Examples of org.eclipse.xtext.nodemodel.INode


  protected void emitHiddenTokens(List<INode> hiddens /* Set<INode> comments, */) {
    if(hiddens == null)
      return;
    boolean lastNonWhitespace = true;
    AbstractRule ws = hiddenTokenHelper.getWhitespaceRuleFor(null, "");
    INode prevCommentNode = null;
    for(INode node : hiddens)
      if(tokenUtil.isCommentNode(node)) {
        if(lastNonWhitespace) {
          String wsString = commentReconcilement != null
              ? commentReconcilement.getWhitespaceBetween(prevCommentNode, node)
View Full Code Here


    if(node == null)
      return Collections.emptySet();
    Set<INode> result = Sets.newHashSet();
    BidiTreeIterator<INode> ti = node.getAsTreeIterable().iterator();
    while(ti.hasNext()) {
      INode next = ti.next();
      if(next.getSemanticElement() != null && next.getSemanticElement() != semanticObject) {
        ti.prune();
        continue;
      }
      if(tokenUtil.isCommentNode(next))
        result.add(next);
View Full Code Here

    if(from == null || to == null)
      return null;
    List<INode> out = Lists.newArrayList();
    NodeIterator ni = new NodeIterator(from);
    while(ni.hasNext()) {
      INode next = ni.next();
      if(tokenUtil.isWhitespaceOrCommentNode(next)) {
        out.add(next);
      }
      else if(next.equals(to)) {
        if(next instanceof ICompositeNode &&
            (GrammarUtil.isDatatypeRuleCall(next.getGrammarElement()) ||
                GrammarUtil.isEnumRuleCall(next.getGrammarElement()) || next.getGrammarElement() instanceof CrossReference))
          while(ni.hasNext()) {
            INode next2 = ni.next();
            if(tokenUtil.isWhitespaceOrCommentNode(next2)) {
              out.add(next2);
            }
            else if(next2 instanceof ILeafNode)
              return out;
View Full Code Here

    if(from == null || root == null)
      return Collections.emptyList();
    List<INode> out = Lists.newArrayList();
    NodeIterator ni = new NodeIterator(from);
    while(ni.hasNext()) {
      INode next = ni.next();
      if(next.getTotalOffset() > root.getTotalEndOffset())
        return out;
      else if(tokenUtil.isWhitespaceOrCommentNode(next)) {
        out.add(next);
      }
      else if(tokenUtil.isToken(next))
View Full Code Here

    //
    if(currentResult != null) {
      {
        ListIterator<INode> litor = currentResult.listIterator();
        while(litor.hasNext()) {
          INode n = litor.next();
          if(tokenUtil.isCommentNode(n) && commentReconcilement.isReconciledCommentNode(n))
            litor.remove();
        }
      }
      // Add the comment nodes the reconciler has for this position
      // (possibly something just removed - that is expected)

      // Also, remove whitespace from current result, if there is any reconciled comments
      if(result.size() > 0) {
        ListIterator<INode> litor = currentResult.listIterator();
        while(litor.hasNext()) {
          INode n = litor.next();
          if(tokenUtil.isWhitespaceNode(n))
            litor.remove();
        }
      }
      for(INode n : result)
View Full Code Here

   */
  @Override
  public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
    super.createHyperlinksByOffset(resource, offset, acceptor);

    INode crossRefNode = ppObjectAtOffsetHelper.getCrossReferenceNode(resource, new TextRegion(offset, 0));
    if(crossRefNode == null)
      return;
    List<IEObjectDescription> crossLinkedObjects = ppObjectAtOffsetHelper.getCrossReferencedElement(crossRefNode);
    Region region = new Region(crossRefNode.getOffset(), crossRefNode.getLength());
    if(crossLinkedObjects != null)
      for(IEObjectDescription iod : crossLinkedObjects)
        createHyperlinksTo(resource, region, iod, acceptor);

  }
View Full Code Here

     * Returns the comment type based on the node's attached {@code INode} if available, otherwise
     * the node's attached <i>grammar element</i>. The node must be a leaf node.
     */
    @Override
    public CommentType classify(IDomNode node) {
      INode inode = node.getNode();
      if(inode != null)
        return classify(inode);
      if(node.isLeaf())
        return classify(node.getGrammarElement());
      return CommentType.Unknown;
View Full Code Here

      result.append(new GrammarElementTitleSwitch().doSwitch(node.getGrammarElement()));
      String newPrefix = prefix + "  ";
      result.append(" {");
      BidiIterator<INode> children = ((ICompositeNode) node).getChildren().iterator();
      while(children.hasNext()) {
        INode child = children.next();
        compactDump(child, showHidden, newPrefix, result);
      }
      result.append("\n");
      result.append(prefix);
      result.append("}");
View Full Code Here

  private void doFormat(EObject o, ITextFlow stream) {
    // EObject context = getContext(o);

    Iterator<INode> itor = commentAssociations.before(o);
    while(itor.hasNext()) {
      INode n = itor.next();
      stream.appendText(n.getText());
    }

    formatDispatcher.invoke(o, stream);
    itor = commentAssociations.after(o);
    while(itor.hasNext()) {
      INode n = itor.next();
      stream.appendText(n.getText());
    }
  }
View Full Code Here

        return PPHighlightConfiguration.DOCUMENTATION_ID;
    }
  }

  private void highlightObject(EObject semantic, String highlightID, IHighlightedPositionAcceptor acceptor) {
    INode node = NodeModelUtils.getNode(semantic);
    if(node == null) {
      // TODO: WARNING - no node
      return;
    }
    acceptor.addPosition(node.getOffset(), node.getLength(), highlightID);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.nodemodel.INode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.