Package org.codehaus.groovy.antlr

Examples of org.codehaus.groovy.antlr.GroovySourceAST


        }
    }

    protected void accept_v_FirstChild_2ndv_SecondChild_v___LastChild_v(GroovySourceAST t) {
        openingVisit(t);
        GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
        if (child != null) {
            accept(child);
            GroovySourceAST sibling = (GroovySourceAST) child.getNextSibling();
            if (sibling != null) {
                secondVisit(t);
                accept(sibling);
                sibling = (GroovySourceAST) sibling.getNextSibling();
                while (sibling != null) {
                    subsequentVisit(t);
                    accept(sibling);
                    sibling = (GroovySourceAST) sibling.getNextSibling();
                }
            }
        }
        closingVisit(t);
    }
View Full Code Here


        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);
    }
View Full Code Here

        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();
            }
        }


    }
View Full Code Here

        closingVisit(t);
    }

    protected void acceptSiblings(GroovySourceAST t) {
        if (t != null) {
            GroovySourceAST sibling = (GroovySourceAST) t.getNextSibling();
            while (sibling != null) {
                accept(sibling);
                sibling = (GroovySourceAST) sibling.getNextSibling();
            }
        }
    }
View Full Code Here

        }
    }

    protected void acceptChildren(GroovySourceAST t) {
        if (t != null) {
            GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
            if (child != null) {
                accept(child);
                acceptSiblings(child);
            }
        }
View Full Code Here

        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);
View Full Code Here

    private void traverse(GroovySourceAST t) {
        if (t == null) { return; }
        if (unvisitedNodes != null) {
           unvisitedNodes.add(t);
        }
        GroovySourceAST child = (GroovySourceAST)t.getFirstChild();
        if (child != null) {
            traverse(child);
        }
        GroovySourceAST sibling = (GroovySourceAST)t.getNextSibling();
        if (sibling != null) {
            traverse(sibling);
        }
    }
View Full Code Here

        }
    }

    protected void accept(GroovySourceAST currentNode) {
        if (currentNode != null && unvisitedNodes != null && unvisitedNodes.size() > 0) {
            GroovySourceAST t = currentNode;

            if (!(unvisitedNodes.contains(currentNode))) {
                return;
            }
            push(t);
            switch (t.getType()) {
                case GroovyTokenTypes.QUESTION: // expr?foo:bar
                    accept_FirstChild_v_SecondChild_v_ThirdChild_v(t);
                    break;

                case GroovyTokenTypes.CASE_GROUP: //
                case GroovyTokenTypes.LITERAL_instanceof: // foo instanceof MyType
                    accept_FirstChild_v_SecondChildsChildren_v(t);
                    break;

                case GroovyTokenTypes.ANNOTATION:
                    accept_v_FirstChild_2ndv_SecondChild_v___LastChild_v(t);
                    break;

                case GroovyTokenTypes.CLOSURE_LIST: // (a=1; a<10; a++)
                case GroovyTokenTypes.ELIST: // a,b,c
                case GroovyTokenTypes.PARAMETERS: // a,b,c
                case GroovyTokenTypes.TYPE_ARGUMENTS: // <String, Object>
                case GroovyTokenTypes.STRING_CONSTRUCTOR: // "foo${bar}wibble"
                case GroovyTokenTypes.TYPE_PARAMETER: // class Foo<T extends F>
                case GroovyTokenTypes.TYPE_PARAMETERS: // class Foo<T>
                case GroovyTokenTypes.TYPE_UPPER_BOUNDS: // class Foo<T extends F>
                    accept_v_FirstChild_v_SecondChild_v___LastChild_v(t);
                    // todo : confirm that TYPE_LOWER_BOUNDS does not have multiple children
                    break;

                case GroovyTokenTypes.VARIABLE_PARAMETER_DEF: // void f(String ... others) {}
                    accept_v_FirstChild_SecondChild_v_ThirdChild_v(t);
                    break;

                case GroovyTokenTypes.INDEX_OP:
                    //accept_FirstChild_v_SecondChild_v(t);
                    accept_SecondChild_v_ThirdChild_v(t);
                    break;

                case GroovyTokenTypes.ENUM_CONSTANT_DEF: // enum Foo(THESE,ARE,THEY)
                case GroovyTokenTypes.EXPR:
                case GroovyTokenTypes.IMPORT:
                case GroovyTokenTypes.STATIC_IMPORT:
                case GroovyTokenTypes.VARIABLE_DEF:
                case GroovyTokenTypes.METHOD_DEF:
                case GroovyTokenTypes.OBJBLOCK: //class Foo {def bar()}  <-- this block
                case GroovyTokenTypes.PARAMETER_DEF: // void f(String me) {}
                case GroovyTokenTypes.SLIST: // list of expressions, variable defs etc
                    accept_v_AllChildren_v(t);
                    break;

                case GroovyTokenTypes.ANNOTATION_MEMBER_VALUE_PAIR: // @Blue(foo=123)
                case GroovyTokenTypes.ASSIGN: // a = b
                case GroovyTokenTypes.BAND_ASSIGN: // a &= b
                case GroovyTokenTypes.BOR_ASSIGN: // a |= b
                case GroovyTokenTypes.BSR_ASSIGN: // a >>>= b
                case GroovyTokenTypes.BXOR_ASSIGN: // a ^= b
                case GroovyTokenTypes.COMPARE_TO: // a <=> b
                case GroovyTokenTypes.DIV_ASSIGN: // a /= b
                case GroovyTokenTypes.EQUAL: // a == b
                case GroovyTokenTypes.MINUS_ASSIGN: // a -= b
                case GroovyTokenTypes.MOD_ASSIGN: // a %= b
                case GroovyTokenTypes.NOT_EQUAL: // a != b
                case GroovyTokenTypes.PLUS_ASSIGN: // a += b
                case GroovyTokenTypes.REGEX_FIND: // a =~ b
                case GroovyTokenTypes.REGEX_MATCH: // a ==~ b
                case GroovyTokenTypes.SL_ASSIGN: // a <<= b
                case GroovyTokenTypes.SR_ASSIGN: // a >>= b
                case GroovyTokenTypes.STAR_ASSIGN: // a *= b
                case GroovyTokenTypes.STAR_STAR_ASSIGN: // x **= 3
                    if (t.childAt(1) != null) {
                        accept_FirstChild_v_RestOfTheChildren(t);
                    } else {
                        accept_v_FirstChild_v_RestOfTheChildren(t);
                    }
                    break;

                case GroovyTokenTypes.ANNOTATION_FIELD_DEF: // @interface Foo{ int bar()...
                    accept_FirstSecondAndThirdChild_v_v_ForthChild(t);
                    break;
                   
                case GroovyTokenTypes.ANNOTATION_DEF: // @interface Foo...
                case GroovyTokenTypes.BAND: // 1 & 2
                case GroovyTokenTypes.BOR: // 1 | 2
                case GroovyTokenTypes.BSR: // 1 >>> 2
                case GroovyTokenTypes.BXOR: // 1 ^ 2
                case GroovyTokenTypes.CLASS_DEF: // class Foo...
                case GroovyTokenTypes.CTOR_IDENT: // private Foo() {...
                case GroovyTokenTypes.DIV: //  3/4
                case GroovyTokenTypes.DOT: // foo.bar
                case GroovyTokenTypes.ENUM_DEF: // enum Foo...
                case GroovyTokenTypes.GE: // a >= b
                case GroovyTokenTypes.GT: // a > b
                case GroovyTokenTypes.INTERFACE_DEF: // interface Foo...
                case GroovyTokenTypes.LABELED_ARG: // myMethod(name:"Jez")
                case GroovyTokenTypes.LABELED_STAT: // foo:x=1                       
                case GroovyTokenTypes.LAND: // true && false
                case GroovyTokenTypes.LE: // a <= b
                case GroovyTokenTypes.LITERAL_as: // foo as Bar
                case GroovyTokenTypes.LITERAL_in: // if (i in myList) ...
                case GroovyTokenTypes.LOR: // true && false
                case GroovyTokenTypes.LT: // a < b
                case GroovyTokenTypes.MEMBER_POINTER: // this.&foo()
                case GroovyTokenTypes.MOD: //  4 % 3
                case GroovyTokenTypes.MINUS: // 1 - 1
                case GroovyTokenTypes.OPTIONAL_DOT: // foo?.bar
                case GroovyTokenTypes.PACKAGE_DEF:
                case GroovyTokenTypes.PLUS: // 1 + 1
                case GroovyTokenTypes.RANGE_EXCLUSIVE: // [1..<10]
                case GroovyTokenTypes.RANGE_INCLUSIVE: // [1..10]
                case GroovyTokenTypes.SL: // a << b
                case GroovyTokenTypes.SPREAD_DOT: // foo*.bar
                case GroovyTokenTypes.SR: // a >> b
                case GroovyTokenTypes.STAR: // a * b   or    import foo.*
                case GroovyTokenTypes.STAR_STAR: // x ** 3
                    accept_FirstChild_v_RestOfTheChildren(t);
                    break;

                case GroovyTokenTypes.CTOR_CALL:
                case GroovyTokenTypes.METHOD_CALL:
                    if (t.getNumberOfChildren() == 2 && t.childAt(1) != null && t.childAt(1).getType() == GroovyTokenTypes.CLOSABLE_BLOCK) {
                        // myMethod {...
                        accept_FirstChild_v_SecondChild(t);
                    } else {
                        GroovySourceAST lastChild = t.childAt(t.getNumberOfChildren() -1);
                        if (lastChild != null && lastChild.getType() == GroovyTokenTypes.CLOSABLE_BLOCK) {
                            // myMethod(a,b) {...
                            accept_FirstChild_v_RestOfTheChildren_v_LastChild(t);
                        } else {
                            // myMethod(a,b)
                            accept_FirstChild_v_RestOfTheChildren_v(t);
View Full Code Here

    }

    private List<GroovySourceAST> findTypeNames(GroovySourceAST t) {
        List<GroovySourceAST> types = new ArrayList<GroovySourceAST>();
        for (AST child = t.getFirstChild(); child != null; child = child.getNextSibling()) {
            GroovySourceAST groovySourceAST = (GroovySourceAST) child;
            if (groovySourceAST.getType() == TYPE) {
                types.add((GroovySourceAST) groovySourceAST.getFirstChild());
            } else {
                types.add(groovySourceAST);
            }
        }
        return types;
View Full Code Here

        values.setReturnType(new SimpleGroovyType(currentClassDoc.name() + "[]"));
        currentClassDoc.add(values);
    }

    private String extractImportPath(GroovySourceAST t) {
        GroovySourceAST child = t.childOfType(DOT);
        if (child == null) {
            child = t.childOfType(IDENT);
        }
        return recurseDownImportBranch(child);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.antlr.GroovySourceAST

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.