Package japa.parser.ast

Examples of japa.parser.ast.Node


  }

  protected <T extends Node> T cloneNodes(T _node, Object _arg) {
    if (_node == null)
      return null;
    Node r = _node.accept(this, _arg);
    if (r == null)
      return null;
    return (T) r;
  }
View Full Code Here


       if (everything.size()==0) return;

       int commentsAtEnd = 0;
       boolean findingComments = true;
       while (findingComments&&commentsAtEnd<everything.size()){
           Node last = everything.get(everything.size()-1-commentsAtEnd);
           findingComments = (last instanceof Comment);
           if (findingComments) commentsAtEnd++;
       }
       for (int i=0;i<commentsAtEnd;i++){
          everything.get(everything.size()-commentsAtEnd+i).accept(this,null);
View Full Code Here

    }

    private void printOrphanCommentsBeforeThisChildNode(final Node node){
        if (node instanceof Comment) return;

        Node parent = node.getParentNode();
        if (parent==null) return;
        List<Node> everything = new LinkedList<Node>();
        everything.addAll(parent.getChildrenNodes());
        sortByBeginPosition(everything);
        int positionOfTheChild = -1;
        for (int i=0;i<everything.size();i++){
            if (everything.get(i)==node) positionOfTheChild=i;
        }
        if (positionOfTheChild==-1) throw new RuntimeException("My index not found!!! "+node);
        int positionOfPreviousChild = -1;
        for (int i=positionOfTheChild-1;i>=0 && positionOfPreviousChild==-1;i--){
            if (!(everything.get(i) instanceof Comment)) positionOfPreviousChild = i;
        }
        for (int i=positionOfPreviousChild+1;i<positionOfTheChild;i++){
            Node nodeToPrint = everything.get(i);
            if (!(nodeToPrint instanceof Comment)) throw new RuntimeException("Expected comment, instead "+nodeToPrint.getClass()+". Position of previous child: "+positionOfPreviousChild+", position of child "+positionOfTheChild);
            nodeToPrint.accept(this,null);
        }
    }
View Full Code Here

TOP

Related Classes of japa.parser.ast.Node

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.