use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.
the class AbstractASTTransformation method getMemberList.
@Deprecated
public List<String> getMemberList(AnnotationNode anno, String name) {
List<String> list;
Expression expr = anno.getMember(name);
if (expr != null && expr instanceof ListExpression) {
list = new ArrayList<String>();
final ListExpression listExpression = (ListExpression) expr;
for (Expression itemExpr : listExpression.getExpressions()) {
if (itemExpr != null && itemExpr instanceof ConstantExpression) {
Object value = ((ConstantExpression) itemExpr).getValue();
if (value != null)
list.add(value.toString());
}
}
} else {
list = tokenize(getMemberStringValue(anno, name));
}
return list;
}
use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.
the class ImmutableASTTransformation method getKnownImmutables.
private List<String> getKnownImmutables(AnnotationNode node) {
final List<String> immutables = new ArrayList<String>();
final Expression expression = node.getMember(MEMBER_KNOWN_IMMUTABLES);
if (expression == null)
return immutables;
if (!(expression instanceof ListExpression)) {
addError("Use the Groovy list notation [el1, el2] to specify known immutable property names via \"" + MEMBER_KNOWN_IMMUTABLES + "\"", node);
return immutables;
}
final ListExpression listExpression = (ListExpression) expression;
for (Expression listItemExpression : listExpression.getExpressions()) {
if (listItemExpression instanceof ConstantExpression) {
immutables.add((String) ((ConstantExpression) listItemExpression).getValue());
}
}
return immutables;
}
use of org.codehaus.groovy.ast.expr.ListExpression 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