Search in sources :

Example 61 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class SimpleGroovyClassDocAssembler method getGrandParentNode.

private GroovySourceAST getGrandParentNode() {
    GroovySourceAST grandParentNode = null;
    GroovySourceAST parentNode;
    GroovySourceAST currentNode = stack.pop();
    if (!stack.empty()) {
        parentNode = stack.pop();
        if (!stack.empty()) {
            grandParentNode = stack.peek();
        }
        stack.push(parentNode);
    }
    stack.push(currentNode);
    return grandParentNode;
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 62 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class SimpleGroovyClassDocAssembler method getTypeArguments.

private void getTypeArguments(GroovySourceAST child, StringBuilder result, String defaultText) {
    if (child != null && child.getType() == TYPE_ARGUMENTS && child.getNumberOfChildren() > 0) {
        result.append("<");
        GroovySourceAST typeArgumentsNext = (GroovySourceAST) child.getFirstChild();
        List<String> typeArgumentParts = new ArrayList<String>();
        while (typeArgumentsNext != null) {
            if (typeArgumentsNext.getType() == TYPE_ARGUMENT && typeArgumentsNext.getNumberOfChildren() > 0) {
                typeArgumentParts.add(getTypeNodeAsText((GroovySourceAST) typeArgumentsNext.getFirstChild(), defaultText));
            }
            typeArgumentsNext = (GroovySourceAST) typeArgumentsNext.getNextSibling();
        }
        result.append(DefaultGroovyMethods.join(typeArgumentParts, ", "));
        result.append(">");
    }
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 63 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class SimpleGroovyClassDocAssembler method getParentNode.

private GroovySourceAST getParentNode() {
    GroovySourceAST parentNode = null;
    GroovySourceAST currentNode = stack.pop();
    if (!stack.empty()) {
        parentNode = stack.peek();
    }
    stack.push(currentNode);
    return parentNode;
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 64 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class SimpleGroovyClassDocAssembler method getAnnotationNames.

private List<String> getAnnotationNames(GroovySourceAST modifiers) {
    List<String> annotationNames = new ArrayList<String>();
    List<GroovySourceAST> annotations = modifiers.childrenOfType(ANNOTATION);
    for (GroovySourceAST annotation : annotations) {
        annotationNames.add(buildName((GroovySourceAST) annotation.getFirstChild()));
    }
    return annotationNames;
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 65 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class SimpleGroovyClassDocAssembler method getTypeParameters.

private void getTypeParameters(GroovySourceAST child, StringBuilder result, String defaultText) {
    if (child != null && child.getType() == TYPE_PARAMETERS && child.getNumberOfChildren() > 0) {
        result.append("<");
        GroovySourceAST typeParametersNext = (GroovySourceAST) child.getFirstChild();
        List<String> typeParameterParts = new ArrayList<String>();
        while (typeParametersNext != null) {
            if (typeParametersNext.getType() == TYPE_PARAMETER && typeParametersNext.getNumberOfChildren() > 0) {
                typeParameterParts.add(getTypeNodeAsText((GroovySourceAST) typeParametersNext.getFirstChild(), defaultText));
            }
            typeParametersNext = (GroovySourceAST) typeParametersNext.getNextSibling();
        }
        result.append(DefaultGroovyMethods.join(typeParameterParts, ", "));
        result.append(">");
    }
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Aggregations

GroovySourceAST (org.codehaus.groovy.antlr.GroovySourceAST)77 AST (antlr.collections.AST)4 Iterator (java.util.Iterator)2 List (java.util.List)2 AntlrASTProcessor (org.codehaus.groovy.antlr.AntlrASTProcessor)2 LineColumn (org.codehaus.groovy.antlr.LineColumn)2