Package org.codehaus.groovy.antlr

Examples of org.codehaus.groovy.antlr.GroovySourceAST


        return grandParentNode != null && grandParentNode.getType() == LITERAL_new;
    }

    // return true if a property is found
    private boolean processModifiers(GroovySourceAST t, SimpleGroovyAbstractableElementDoc memberOrClass) {
        GroovySourceAST modifiers = t.childOfType(MODIFIERS);
        boolean hasNonPublicVisibility = false;
        boolean hasPublicVisibility = false;
        if (modifiers != null) {
            AST currentModifier = modifiers.getFirstChild();
            while (currentModifier != null) {
                int type = currentModifier.getType();
                switch (type) {
                    case LITERAL_public:
                        memberOrClass.setPublic(true);
View Full Code Here


    }

    private String buildName(GroovySourceAST t) {
        if (t != null) {
            if (t.getType() == DOT) {
                GroovySourceAST firstChild = (GroovySourceAST) t.getFirstChild();
                GroovySourceAST secondChild = (GroovySourceAST) firstChild.getNextSibling();
                return (buildName(firstChild) + "/" + buildName(secondChild));
            }
            if (t.getType() == IDENT) {
                return t.getText();
            }
View Full Code Here

        }
        return "";
    }

    private String getTypeOrDefault(GroovySourceAST t) {
        GroovySourceAST typeNode = t.childOfType(TYPE);
        return getTypeNodeAsText(typeNode, "def");
    }
View Full Code Here

        }
        return defaultText;
    }

    private String getAsText(GroovySourceAST typeNode, String defaultText) {
        GroovySourceAST child = (GroovySourceAST) typeNode.getFirstChild();
        return getAsTextCurrent(child, defaultText);
    }
View Full Code Here

            // identifiers
            case IDENT:
                return node.getText();
            case DOT:
                List<String> result = new ArrayList<String>();
                GroovySourceAST child = (GroovySourceAST) node.getFirstChild();
                while (child != null) {
                    if (child.getType() == IDENT) { result.add(child.getText()); }
                    else if (child.getType() == DOT) { result.add(getAsTextCurrent(child, defaultText)); }
                    child = (GroovySourceAST) child.getNextSibling();
                }
                return DefaultGroovyMethods.join(result, "/");
        }
        return defaultText;
    }
View Full Code Here

        return defaultText;
    }

    private void addParametersTo(GroovySourceAST t, SimpleGroovyExecutableMemberDoc executableMemberDoc) {
        // parameters
        GroovySourceAST parametersNode = t.childOfType(PARAMETERS);
        if (parametersNode != null && parametersNode.getNumberOfChildren() > 0) {
            GroovySourceAST currentNode = (GroovySourceAST) parametersNode.getFirstChild();
            while (currentNode != null) {
                String parameterTypeName = getTypeOrDefault(currentNode);
                String parameterName = getText(currentNode.childOfType(IDENT));
                SimpleGroovyParameter parameter = new SimpleGroovyParameter(parameterName);
                parameter.setVararg(currentNode.getType() == VARIABLE_PARAMETER_DEF);
                parameter.setTypeName(parameterTypeName);
                GroovySourceAST modifiers = currentNode.childOfType(MODIFIERS);
                if (modifiers != null) {
                    List<GroovySourceAST> annotations = modifiers.childrenOfType(ANNOTATION);
                    for (GroovySourceAST a : annotations) {
                        addAnnotationRef(parameter, a);
                    }
                }
                executableMemberDoc.add(parameter);
View Full Code Here

            }
        }
    }

    private void handleDefaultValue(GroovySourceAST currentNode, SimpleGroovyParameter parameter) {
        GroovySourceAST paramPart = (GroovySourceAST) currentNode.getFirstChild();
        for (int i = 1; i < currentNode.getNumberOfChildren(); i++) {
            paramPart = (GroovySourceAST) paramPart.getNextSibling();
        }
        GroovySourceAST nodeToProcess = paramPart;
        if (paramPart.getNumberOfChildren() > 0) {
            nodeToProcess = (GroovySourceAST) paramPart.getFirstChild();
        }
        // hack warning!
        // TODO handle , and ) when they occur within Strings
View Full Code Here

        }
        return null;
    }

    private GroovySourceAST getParentNode() {
        GroovySourceAST parentNode = null;
        GroovySourceAST currentNode = stack.pop();
        if (!stack.empty()) {
            parentNode = stack.peek();
        }
        stack.push(currentNode);
        return parentNode;
View Full Code Here

        stack.push(currentNode);
        return parentNode;
    }

    private GroovySourceAST getGrandParentNode() {
        GroovySourceAST grandParentNode = null;
        GroovySourceAST parentNode;
        GroovySourceAST currentNode = stack.pop();
        if (!stack.empty()) {
            parentNode = stack.pop();
            if (!stack.empty()) {
                grandParentNode = stack.peek();
            }
View Full Code Here

        return foundClasses.get(getIdentFor(node));
    }

    private SimpleGroovyClassDoc getCurrentClassDoc() {
        if (stack.isEmpty()) return null;
        GroovySourceAST node = getParentNode();
        if (isTopLevelConstruct(node)) return foundClasses.get(getIdentFor(node));
        GroovySourceAST saved = stack.pop();
        SimpleGroovyClassDoc result = getCurrentClassDoc();
        stack.push(saved);
        return result;
    }
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.