Java Code Examples for org.codehaus.groovy.ast.Parameter#setInitialExpression()
The following examples show how to use
org.codehaus.groovy.ast.Parameter#setInitialExpression() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolveVisitor.java From groovy with Apache License 2.0 | 6 votes |
protected Expression transformClosureExpression(final ClosureExpression ce) { boolean oldInClosure = inClosure; inClosure = true; for (Parameter para : getParametersSafe(ce)) { ClassNode t = para.getType(); resolveOrFail(t, ce); visitAnnotations(para); if (para.hasInitialExpression()) { para.setInitialExpression(transform(para.getInitialExpression())); } visitAnnotations(para); } Statement code = ce.getCode(); if (code != null) code.visit(this); inClosure = oldInClosure; return ce; }
Example 2
Source File: StaticImportVisitor.java From groovy with Apache License 2.0 | 5 votes |
protected Expression transformClosureExpression(ClosureExpression ce) { boolean oldInClosure = inClosure; inClosure = true; for (Parameter p : getParametersSafe(ce)) { if (p.hasInitialExpression()) { p.setInitialExpression(transform(p.getInitialExpression())); } } Statement code = ce.getCode(); if (code != null) code.visit(this); inClosure = oldInClosure; return ce; }
Example 3
Source File: ResolveVisitor.java From groovy with Apache License 2.0 | 5 votes |
@Override protected void visitConstructorOrMethod(final MethodNode node, final boolean isConstructor) { VariableScope oldScope = currentScope; currentScope = node.getVariableScope(); Map<GenericsTypeName, GenericsType> oldPNames = genericParameterNames; genericParameterNames = node.isStatic() && !Traits.isTrait(node.getDeclaringClass()) ? new HashMap<>() : new HashMap<>(genericParameterNames); resolveGenericsHeader(node.getGenericsTypes()); Parameter[] paras = node.getParameters(); for (Parameter p : paras) { p.setInitialExpression(transform(p.getInitialExpression())); resolveOrFail(p.getType(), p.getType()); visitAnnotations(p); } ClassNode[] exceptions = node.getExceptions(); for (ClassNode t : exceptions) { resolveOrFail(t, node); } resolveOrFail(node.getReturnType(), node); MethodNode oldCurrentMethod = currentMethod; currentMethod = node; super.visitConstructorOrMethod(node, isConstructor); currentMethod = oldCurrentMethod; genericParameterNames = oldPNames; currentScope = oldScope; }
Example 4
Source File: TupleConstructorASTTransformation.java From groovy with Apache License 2.0 | 5 votes |
private static Parameter createParam(FieldNode fNode, String name, boolean defaults, AbstractASTTransformation xform, boolean makeImmutable) { Parameter param = new Parameter(fNode.getType(), name); if (defaults) { param.setInitialExpression(providedOrDefaultInitialValue(fNode)); } else if (!makeImmutable) { // TODO we could support some default vals provided they were listed last if (fNode.getInitialExpression() != null) { xform.addError("Error during " + MY_TYPE_NAME + " processing, default value processing disabled but default value found for '" + fNode.getName() + "'", fNode); } } return param; }
Example 5
Source File: ClosureExpressionTransformer.java From groovy with Apache License 2.0 | 5 votes |
Expression transformClosureExpression(final ClosureExpression expr) { for (Parameter parameter : getParametersSafe(expr)) { if (parameter.hasInitialExpression()) { parameter.setInitialExpression(transformer.transform(parameter.getInitialExpression())); } } Statement code = expr.getCode(); transformer.visitClassCodeContainer(code); return transformer.superTransform(expr); }