use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
the class FlatNodeListTraversal method process.
public AST process(AST t) {
GroovySourceAST node = (GroovySourceAST) t;
// fetch all the nodes in this AST into a List
NodeCollector collector = new NodeCollector();
AntlrASTProcessor internalTraversal = new PreOrderTraversal(collector);
internalTraversal.process(t);
List listOfAllNodesInThisAST = collector.getNodes();
// process each node in turn
setUp(node);
Iterator itr = listOfAllNodesInThisAST.iterator();
while (itr.hasNext()) {
GroovySourceAST currentNode = (GroovySourceAST) itr.next();
accept(currentNode);
}
tearDown(node);
return null;
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
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;
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
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;
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
the class SimpleGroovyClassDocAssembler method getIdentPlusTypeArgsFor.
private String getIdentPlusTypeArgsFor(GroovySourceAST gpn) {
GroovySourceAST groovySourceAST = gpn.childOfType(IDENT);
StringBuilder ident = new StringBuilder();
ident.append(groovySourceAST.getText());
GroovySourceAST typeParams = (GroovySourceAST) groovySourceAST.getNextSibling();
getTypeParameters(typeParams, ident, "def");
return ident.toString();
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
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(">");
}
}
Aggregations