Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.AnnotationNode


    private static final String CLOSURE_LABEL = "Closure";
    private static final String METHOD_LABEL = "Priv";

    public void visit(ASTNode[] nodes, final SourceUnit source) {
        init(nodes, source);
        AnnotationNode annotationNode = (AnnotationNode) nodes[0];
        AnnotatedNode annotatedNode = (AnnotatedNode) nodes[1];
        if (MY_TYPE.equals(annotationNode.getClassNode()) && annotatedNode instanceof MethodNode) {
            MethodNode methodNode = (MethodNode) annotatedNode;
            if (methodNode.isAbstract()) {
                addError("Annotation " + MY_TYPE_NAME + " cannot be used for abstract methods.", methodNode);
                return;
            }
View Full Code Here


    private static final ClassNode LIST_TYPE = makeWithoutCaching(List.class, false);

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) return;

        if (parent instanceof FieldNode) {
            FieldNode fNode = (FieldNode) parent;
            ClassNode cNode = fNode.getDeclaringClass();
            if (cNode.getProperty(fNode.getName()) == null) {
View Full Code Here

    static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode anno = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(anno.getClassNode())) return;

        if (parent instanceof ClassNode) {
            ClassNode cNode = (ClassNode) parent;
            // TODO remove - let other validation steps pick this up
            if (hasAnnotation(cNode, ImmutableASTTransformation.MY_TYPE)) {
View Full Code Here

    public void visitAnnotations(AnnotatedNode node) {
        super.visitAnnotations(node);

        List<AnnotationNode> collected = new ArrayList<AnnotationNode>();
        for (Iterator<AnnotationNode> it = node.getAnnotations().iterator(); it.hasNext();) {
            AnnotationNode annotation = it.next();
            if (addCollectedAnnotations(collected, annotation, node)) it.remove();
        }
        node.getAnnotations().addAll(collected);
       
        for (AnnotationNode annotation : node.getAnnotations()) {
            Annotation transformClassAnnotation = getTransformClassAnnotation(annotation.getClassNode());
            if (transformClassAnnotation == null) {
                // skip if there is no such annotation
                continue;
            }
            addTransformsToClassNode(annotation, transformClassAnnotation);
View Full Code Here

    private static final String ARG0 = "arg0";
    private static final String ARG1 = "arg1";

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotationNode annotation = (AnnotationNode) nodes[0];
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        if (parent instanceof ClassNode) {
            createSortable(annotation, (ClassNode) parent);
        }
    }
View Full Code Here

        return EMPTY_CLASS_ARRAY;
    }

    private void setAnnotationMetaData(Annotation[] annotations, AnnotatedNode an) {
        for (Annotation annotation : annotations) {
            AnnotationNode node = new AnnotationNode(ClassHelper.make(annotation.annotationType()));
            configureAnnotation(node, annotation);
            an.addAnnotation(node);
        }
    }
View Full Code Here

    public static final String DEFAULT_INSTANCE_LOCKNAME = "$reentrantlock";

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        final boolean isWriteLock;
        if (READ_LOCK_TYPE.equals(node.getClassNode())) {
            isWriteLock = false;
        } else if (WRITE_LOCK_TYPE.equals(node.getClassNode())) {
            isWriteLock = true;
        } else {
            throw new GroovyBugError("Internal error: expecting [" + READ_LOCK_TYPE.getName() + ", " + WRITE_LOCK_TYPE.getName() + "]" + " but got: " + node.getClassNode().getName());
        }

        String myTypeName = "@" + node.getClassNode().getNameWithoutPackage();

        String value = getMemberStringValue(node, "value");

        if (parent instanceof MethodNode) {
            MethodNode mNode = (MethodNode) parent;
View Full Code Here

  }

  private void addEnableAutoConfigurationAnnotation(SourceUnit source,
      ClassNode classNode) {
    if (!hasEnableAutoConfigureAnnotation(classNode)) {
      AnnotationNode annotationNode = new AnnotationNode(
          ClassHelper.make("EnableAutoConfiguration"));
      classNode.addAnnotation(annotationNode);
    }
  }
View Full Code Here

  @Override
  public void apply(GroovyClassLoader loader,
      GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
      SourceUnit source, ClassNode classNode) throws CompilationFailedException {
    if (!AstUtils.hasAtLeastOneAnnotation(classNode, "RunWith")) {
      AnnotationNode runwith = new AnnotationNode(ClassHelper.make("RunWith"));
      runwith.addMember("value",
          new ClassExpression(ClassHelper.make("SpringJUnit4ClassRunner")));
      classNode.addAnnotation(runwith);
    }
  }
View Full Code Here

    return this;
  }

  private AnnotationNode createGrabAnnotation(String group, String module,
      String version, String classifier, String type, boolean transitive) {
    AnnotationNode annotationNode = new AnnotationNode(new ClassNode(Grab.class));
    annotationNode.addMember("group", new ConstantExpression(group));
    annotationNode.addMember("module", new ConstantExpression(module));
    annotationNode.addMember("version", new ConstantExpression(version));
    if (classifier != null) {
      annotationNode.addMember("classifier", new ConstantExpression(classifier));
    }
    if (type != null) {
      annotationNode.addMember("type", new ConstantExpression(type));
    }
    annotationNode.addMember("transitive", new ConstantExpression(transitive));
    annotationNode.addMember("initClass", new ConstantExpression(false));
    return annotationNode;
  }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.AnnotationNode

Copyright © 2018 www.massapicom. 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.