use of org.codehaus.groovy.ast.expr.ClassExpression in project groovy by apache.
the class AutoCloneASTTransformation method getStyle.
private static AutoCloneStyle getStyle(AnnotationNode node, String name) {
final Expression member = node.getMember(name);
if (member != null && member instanceof PropertyExpression) {
PropertyExpression prop = (PropertyExpression) member;
Expression oe = prop.getObjectExpression();
if (oe instanceof ClassExpression) {
ClassExpression ce = (ClassExpression) oe;
if (ce.getType().getName().equals("groovy.transform.AutoCloneStyle")) {
return AutoCloneStyle.valueOf(prop.getPropertyAsString());
}
}
}
return null;
}
use of org.codehaus.groovy.ast.expr.ClassExpression in project groovy by apache.
the class NewifyASTTransformation method checkDuplicateNameClashes.
private void checkDuplicateNameClashes(ListExpression list) {
final Set<String> seen = new HashSet<String>();
@SuppressWarnings("unchecked") final List<ClassExpression> classes = (List) list.getExpressions();
for (ClassExpression ce : classes) {
final String name = ce.getType().getNameWithoutPackage();
if (seen.contains(name)) {
addError("Duplicate name '" + name + "' found during @" + MY_NAME + " processing.", ce);
}
seen.add(name);
}
}
use of org.codehaus.groovy.ast.expr.ClassExpression in project groovy by apache.
the class CompileDynamicProcessor method visit.
public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source) {
AnnotationNode node = new AnnotationNode(COMPILESTATIC_NODE);
node.addMember("value", new PropertyExpression(new ClassExpression(TYPECHECKINGMODE_NODE), "SKIP"));
return Collections.singletonList(node);
}
use of org.codehaus.groovy.ast.expr.ClassExpression in project groovy by apache.
the class ImmutableASTTransformation method getKnownImmutableClasses.
private List<String> getKnownImmutableClasses(AnnotationNode node) {
final List<String> immutableClasses = new ArrayList<String>();
final Expression expression = node.getMember(MEMBER_KNOWN_IMMUTABLE_CLASSES);
if (expression == null)
return immutableClasses;
if (!(expression instanceof ListExpression)) {
addError("Use the Groovy list notation [el1, el2] to specify known immutable classes via \"" + MEMBER_KNOWN_IMMUTABLE_CLASSES + "\"", node);
return immutableClasses;
}
final ListExpression listExpression = (ListExpression) expression;
for (Expression listItemExpression : listExpression.getExpressions()) {
if (listItemExpression instanceof ClassExpression) {
immutableClasses.add(listItemExpression.getType().getName());
}
}
return immutableClasses;
}
Aggregations