use of org.codehaus.groovy.ast.expr.ConstructorCallExpression in project groovy by apache.
the class NewifyASTTransformation method transform.
public Expression transform(Expression expr) {
if (expr == null)
return null;
if (expr instanceof MethodCallExpression && candidate == null) {
MethodCallExpression mce = (MethodCallExpression) expr;
Expression args = transform(mce.getArguments());
if (isNewifyCandidate(mce)) {
Expression transformed = transformMethodCall(mce, args);
transformed.setSourcePosition(mce);
return transformed;
}
Expression method = transform(mce.getMethod());
Expression object = transform(mce.getObjectExpression());
MethodCallExpression transformed = callX(object, method, args);
transformed.setImplicitThis(mce.isImplicitThis());
transformed.setSourcePosition(mce);
return transformed;
} else if (expr instanceof ClosureExpression) {
ClosureExpression ce = (ClosureExpression) expr;
ce.getCode().visit(this);
} else if (expr instanceof ConstructorCallExpression) {
ConstructorCallExpression cce = (ConstructorCallExpression) expr;
if (cce.isUsingAnonymousInnerClass()) {
cce.getType().visitContents(this);
}
} else if (expr instanceof DeclarationExpression) {
DeclarationExpression de = (DeclarationExpression) expr;
if (de == candidate || auto) {
candidate = null;
Expression left = de.getLeftExpression();
Expression right = transform(de.getRightExpression());
DeclarationExpression newDecl = new DeclarationExpression(left, de.getOperation(), right);
newDecl.addAnnotations(de.getAnnotations());
return newDecl;
}
return de;
}
return expr.transformExpression(this);
}
use of org.codehaus.groovy.ast.expr.ConstructorCallExpression in project groovy by apache.
the class RangeExpressionTransformer method transformRangeExpression.
public Expression transformRangeExpression(RangeExpression range) {
final ClassNode inferred = range.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
if (INTRANGE_TYPE.equals(inferred)) {
ArgumentListExpression bounds = new ArgumentListExpression(new ConstantExpression(range.isInclusive(), true), range.getFrom(), range.getTo());
ConstructorCallExpression cce = new ConstructorCallExpression(INTRANGE_TYPE, bounds);
cce.setSourcePosition(range);
cce.putNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET, INTRANGE_CTOR);
cce.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, INTRANGE_TYPE);
return transformer.transform(cce);
}
return transformer.superTransform(range);
}
use of org.codehaus.groovy.ast.expr.ConstructorCallExpression in project gradle by gradle.
the class GradleResolveVisitor method transformConstructorCallExpression.
protected Expression transformConstructorCallExpression(ConstructorCallExpression cce) {
ClassNode type = cce.getType();
resolveOrFail(type, cce);
if (Modifier.isAbstract(type.getModifiers())) {
addError("You cannot create an instance from the abstract " + getDescription(type) + ".", cce);
}
Expression ret = cce.transformExpression(this);
return ret;
}
Aggregations