Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.ClassNode.addMethod()


        BlockStatement body = new BlockStatement();
        Parameter[] theParams = params(
                new Parameter(ClassHelper.int_TYPE, "index"),
                new Parameter(componentType, "value"));
        body.addStatement(assignS(indexX(varX(fNode), varX(theParams[0])), varX(theParams[1])));
        cNode.addMethod(makeName(fNode, "set"), getModifiers(fNode), ClassHelper.VOID_TYPE, theParams, null, body);
    }

    private ClassNode getComponentTypeForList(ClassNode fType) {
        if (fType.isUsingGenerics() && fType.getGenericsTypes().length == 1) {
            return fType.getGenericsTypes()[0].getType();
View Full Code Here


    ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
    this.moduleNode.addClass(classNode);

    ConstructorNode constructorNode = new ConstructorNode(0, null);
    constructorNode.addAnnotation(this.grabAnnotation);
    classNode.addMethod(constructorNode);

    assertGrabAnnotationHasBeenTransformation();
  }

  @Test
View Full Code Here

    this.moduleNode.addClass(classNode);

    MethodNode methodNode = new MethodNode("test", 0, new ClassNode(Void.class),
        new Parameter[0], new ClassNode[0], null);
    methodNode.addAnnotation(this.grabAnnotation);
    classNode.addMethod(methodNode);

    assertGrabAnnotationHasBeenTransformation();
  }

  @Test
View Full Code Here

    Parameter parameter = new Parameter(new ClassNode(Object.class), "test");
    parameter.addAnnotation(this.grabAnnotation);

    MethodNode methodNode = new MethodNode("test", 0, new ClassNode(Void.class),
        new Parameter[] { parameter }, new ClassNode[0], null);
    classNode.addMethod(methodNode);

    assertGrabAnnotationHasBeenTransformation();
  }

  @Test
View Full Code Here

        new VariableScope());

    MethodNode methodNode = new MethodNode("test", 0, new ClassNode(Void.class),
        new Parameter[0], new ClassNode[0], code);

    classNode.addMethod(methodNode);

    assertGrabAnnotationHasBeenTransformation();
  }

  private AnnotationNode createGrabAnnotation() {
View Full Code Here

                new BinaryExpression(
                        new VariableExpression(fNode.getName()),
                        INDEX,
                        new VariableExpression(params[0]))
        ));
        cNode.addMethod(makeName(fNode, "get"), getModifiers(fNode), componentType, params, null, body);
    }

    private void addSetter(FieldNode fNode, ClassNode componentType) {
        ClassNode cNode = fNode.getDeclaringClass();
        BlockStatement body = new BlockStatement();
View Full Code Here

                                INDEX,
                                new VariableExpression(params[0])),
                        ASSIGN,
                        new VariableExpression(params[1])
                )));
        cNode.addMethod(makeName(fNode, "set"), getModifiers(fNode), ClassHelper.VOID_TYPE, params, null, body);
    }

    private ClassNode getComponentTypeForList(ClassNode fType) {
        if (fType.isUsingGenerics() && fType.getGenericsTypes().length == 1) {
            return fType.getGenericsTypes()[0].getType();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.