traversalhelper.java

来自「大名鼎鼎的java动态脚本语言。已经通过了sun的认证」· Java 代码 · 共 478 行 · 第 1/3 页

JAVA
478
字号
        subsequentVisit(t);        accept(t.childAt(1));    }    protected void accept_FirstChild_v_SecondChild_v(GroovySourceAST t) {        accept(t.childAt(0));        openingVisit(t);        accept(t.childAt(1));        closingVisit(t);    }    protected void accept_FirstChild_v_SecondChildsChildren_v(GroovySourceAST t) {        accept(t.childAt(0));        openingVisit(t);        GroovySourceAST secondChild = t.childAt(1);        if (secondChild != null) {            acceptChildren(secondChild);        }        closingVisit(t);    }    protected void accept_FirstChild_v_SecondChild_v_ThirdChild_v(GroovySourceAST t) {        accept(t.childAt(0));        openingVisit(t);        accept(t.childAt(1));        subsequentVisit(t);        accept(t.childAt(2));        closingVisit(t);    }    protected void accept_v_FirstChild_v_SecondChild_v___LastChild_v(GroovySourceAST t) {        openingVisit(t);        GroovySourceAST child = (GroovySourceAST)t.getFirstChild();        if (child != null){            accept(child);            GroovySourceAST sibling = (GroovySourceAST)child.getNextSibling();            while (sibling != null) {                subsequentVisit(t);                accept(sibling);                sibling = (GroovySourceAST)sibling.getNextSibling();            }        }        closingVisit(t);    }    protected void accept_v_FirstChild_v(GroovySourceAST t) {        openingVisit(t);        accept(t.childAt(0));        closingVisit(t);    }    protected void accept_v_AllChildren_v_Siblings(GroovySourceAST t) {        openingVisit(t);        acceptChildren(t);        closingVisit(t);        acceptSiblings(t);    }    protected void accept_v_AllChildren_v(GroovySourceAST t) {        openingVisit(t);        acceptChildren(t);        closingVisit(t);    }    protected void accept_FirstChild_v_RestOfTheChildren(GroovySourceAST t) {        accept(t.childAt(0));        openingVisit(t);        closingVisit(t);        acceptSiblings(t.childAt(0));    }    protected void accept_FirstChild_v_RestOfTheChildren_v_LastChild(GroovySourceAST t) {        int count = 0;        accept(t.childAt(0));        count++;        openingVisit(t);        if (t.childAt(0) != null) {            GroovySourceAST sibling = (GroovySourceAST)t.childAt(0).getNextSibling();            while (sibling != null) {                if (count == t.getNumberOfChildren() - 1) {closingVisit(t);}                accept(sibling);                count++;                sibling = (GroovySourceAST)sibling.getNextSibling();            }        }    }    protected void accept_FirstChild_v_RestOfTheChildren_v(GroovySourceAST t) {        accept(t.childAt(0));        openingVisit(t);        acceptSiblings(t.childAt(0));        closingVisit(t);    }    protected void accept_v_FirstChild_v_RestOfTheChildren(GroovySourceAST t) {        accept_v_FirstChild_v(t);        acceptSiblings(t.childAt(0));    }    protected void accept_v_FirstChild_v_RestOfTheChildren_v(GroovySourceAST t) {        openingVisit(t);        accept(t.childAt(0));        subsequentVisit(t);        acceptSiblings(t.childAt(0));        closingVisit(t);    }    protected void acceptSiblings(GroovySourceAST t) {        if (t != null) {            GroovySourceAST sibling = (GroovySourceAST)t.getNextSibling();            while (sibling != null) {                accept(sibling);                sibling = (GroovySourceAST)sibling.getNextSibling();            }        }    }    protected void acceptChildren(GroovySourceAST t) {        if (t != null) {            GroovySourceAST child = (GroovySourceAST)t.getFirstChild();            if (child != null){                accept(child);                acceptSiblings(child);            }        }    }    protected void skip(GroovySourceAST expr) {        unvisitedNodes.remove(expr);    }    protected void openingVisit(GroovySourceAST t) {        unvisitedNodes.remove(t);        int n = Visitor.OPENING_VISIT;        visitNode(t, n);    }    protected void subsequentVisit(GroovySourceAST t) {        int n = Visitor.SUBSEQUENT_VISIT;        visitNode(t, n);    }    protected void closingVisit(GroovySourceAST t) {        int n = Visitor.CLOSING_VISIT;        visitNode(t, n);    }        public AST process(AST t) {        GroovySourceAST node = (GroovySourceAST) t;                // process each node in turn        setUp(node);        accept(node);        acceptSiblings(node);        tearDown(node);        return null;    }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?