use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
the class TraversalHelper method acceptChildren.
protected void acceptChildren(GroovySourceAST t) {
if (t != null) {
GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
if (child != null) {
accept(child);
acceptSiblings(child);
}
}
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
the class TraversalHelper method accept_FirstChild_v_SecondChildsChildren_v.
protected void accept_FirstChild_v_SecondChildsChildren_v(GroovySourceAST t) {
accept(t.childAt(0));
openingVisit(t);
GroovySourceAST secondChild = t.childAt(1);
if (secondChild != null) {
acceptChildren(secondChild);
}
closingVisit(t);
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.
the class TraversalHelper method acceptSiblings.
protected void acceptSiblings(GroovySourceAST t) {
if (t != null) {
GroovySourceAST sibling = (GroovySourceAST) t.getNextSibling();
while (sibling != null) {
accept(sibling);
sibling = (GroovySourceAST) sibling.getNextSibling();
}
}
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project gradle by gradle.
the class SourceMetaDataVisitor method pop.
public GroovySourceAST pop() {
if (!parseStack.isEmpty()) {
GroovySourceAST ast = parseStack.removeFirst();
ClassMetaData classMetaData = typeTokens.remove(ast);
if (classMetaData != null) {
assert classMetaData == classStack.getFirst();
classStack.removeFirst();
}
return ast;
}
return null;
}
use of org.codehaus.groovy.antlr.GroovySourceAST in project gradle by gradle.
the class SourceMetaDataVisitor method maybeAddPropertyFromField.
private void maybeAddPropertyFromField(GroovySourceAST t) {
GroovySourceAST parentNode = getParentNode();
boolean isField = parentNode != null && parentNode.getType() == OBJBLOCK;
if (!isField) {
return;
}
int modifiers = extractModifiers(t);
boolean isConst = getCurrentClass().isInterface() || (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers));
if (isConst) {
visitConst(t);
return;
}
boolean isProp = groovy && !Modifier.isStatic(modifiers) && !Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isPrivate(modifiers);
if (!isProp) {
return;
}
ASTIterator children = new ASTIterator(t);
children.skip(MODIFIERS);
String propertyName = extractIdent(t);
TypeMetaData propertyType = extractTypeName(children.current);
ClassMetaData currentClass = getCurrentClass();
MethodMetaData getterMethod = currentClass.addMethod(String.format("get%s", StringUtils.capitalize(propertyName)), propertyType, "");
PropertyMetaData property = currentClass.addReadableProperty(propertyName, propertyType, getJavaDocCommentsBeforeNode(t), getterMethod);
findAnnotations(t, property);
if (!Modifier.isFinal(modifiers)) {
MethodMetaData setterMethod = currentClass.addMethod(String.format("set%s", StringUtils.capitalize(propertyName)), TypeMetaData.VOID, "");
setterMethod.addParameter(propertyName, propertyType);
currentClass.addWriteableProperty(propertyName, propertyType, getJavaDocCommentsBeforeNode(t), setterMethod);
}
}
Aggregations