use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.
the class CompositeVisitor method pop.
public GroovySourceAST pop() {
GroovySourceAST lastNodePopped = null;
Iterator itr = backToFrontVisitors.iterator();
while (itr.hasNext()) {
lastNodePopped = (GroovySourceAST) ((Visitor) itr.next()).pop();
}
return lastNodePopped;
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.
the class SourcePrinter method visitType.
// visit TripleDot, not used in the AST
public void visitType(GroovySourceAST t, int visit) {
GroovySourceAST parent = getParentNode();
GroovySourceAST modifiers = parent.childOfType(GroovyTokenTypes.MODIFIERS);
// No need to print 'def' if we already have some modifiers
if (modifiers == null || modifiers.getNumberOfChildren() == 0) {
if (visit == OPENING_VISIT) {
if (t.getNumberOfChildren() == 0 && parent.getType() != GroovyTokenTypes.PARAMETER_DEF) {
// no need for 'def' if in a parameter list
print(t, visit, "def");
}
}
if (visit == CLOSING_VISIT) {
if (parent.getType() == GroovyTokenTypes.VARIABLE_DEF || parent.getType() == GroovyTokenTypes.METHOD_DEF || parent.getType() == GroovyTokenTypes.ANNOTATION_FIELD_DEF || (parent.getType() == GroovyTokenTypes.PARAMETER_DEF && t.getNumberOfChildren() != 0)) {
print(t, visit, " ");
}
}
/*if (visit == CLOSING_VISIT) {
print(t,visit," ");
}*/
} else {
if (visit == CLOSING_VISIT) {
if (t.getNumberOfChildren() != 0) {
print(t, visit, " ");
}
}
}
}
Aggregations