Tabnine Logo
ClassNode.addAnnotation
Code IndexAdd Tabnine to your IDE (free)

How to use
addAnnotation
method
in
org.codehaus.groovy.ast.ClassNode

Best Java code snippets using org.codehaus.groovy.ast.ClassNode.addAnnotation (Showing top 17 results out of 315)

origin: org.codehaus.groovy/groovy

/**
 * Copies annotation from the trait to the helper, excluding the trait annotation itself
 * @param cNode the trait class node
 * @param helper the helper class node
 */
private static void copyClassAnnotations(final ClassNode cNode, final ClassNode helper) {
  List<AnnotationNode> annotations = cNode.getAnnotations();
  for (AnnotationNode annotation : annotations) {
    if (!annotation.getClassNode().equals(Traits.TRAIT_CLASSNODE)) {
      helper.addAnnotation(annotation);
    }
  }
}
origin: spockframework/spock

private void addSpecMetadata(Spec spec) {
 AnnotationNode ann = new AnnotationNode(nodeCache.SpecMetadata);
 String pathname = spec.getAst().getModule().getContext().getName();
 String filename = new File(pathname).getName();
 ann.setMember(SpecMetadata.FILENAME, new ConstantExpression(filename));
 ann.setMember(SpecMetadata.LINE, new ConstantExpression(spec.getAst().getLineNumber()));
 spec.getAst().addAnnotation(ann);
}
origin: org.codehaus.groovy/groovy

private void setScriptBaseClassFromConfig(ClassNode cn) {
  String baseClassName = null;
  if (unit != null) {
    baseClassName = unit.getConfig().getScriptBaseClass();
  } else if (context != null) {
    baseClassName = context.getConfiguration().getScriptBaseClass();
  }
  if (baseClassName != null) {
    if (!cn.getSuperClass().getName().equals(baseClassName)) {
      cn.setSuperClass(ClassHelper.make(baseClassName));
      AnnotationNode annotationNode = new AnnotationNode(BaseScriptASTTransformation.MY_TYPE);
      cn.addAnnotation(annotationNode);
    }
  }
}

origin: org.codehaus.groovy/groovy

    ACC_PUBLIC | ACC_STATIC | ACC_FINAL, ClassHelper.OBJECT_TYPE.getPlainNodeReference());
cn.getModule().addClass(helper);
helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE));
MethodNode serializeClass = collector.getClassNode().getMethod("serializeClass", Parameter.EMPTY_ARRAY);
collector.setMember("serializeClass", new ClassExpression(helper.getPlainNodeReference()));
origin: grooviter/asteroid

private void addAnnotationsFromTo(final AnnotationNode annotationNode, final ClassNode annotatedNode) {
  final String qualifiedName = A.UTIL.NODE.get(annotationNode, String.class);
  final String target        = A.UTIL.NODE.get(annotationNode, "applyTo", String.class);
  annotatedNode.addAnnotation(getTargetAnnotation(target));
  annotatedNode.addAnnotation(getRetentionAnnotation());
  annotatedNode.addAnnotation(getGroovyAnnotationWith(qualifiedName));
}
origin: grooviter/asteroid

/**
 * All transformation will be always annotated with:
 *
 * <ul>
 *    <li>{@link InheritConstructors}</li>
 *    <li>{@link GroovyASTTransformation}</li>
 * </ul>
 *
 * To avoid repeating this over and over again this method adds
 * both to the annotated {@link ClassNode} passed as first
 * argument
 *
 * @param annotated The {@link ClassNode} we want to add both
 * annotations to
 * @param compilePhase The {@link CompilePhase} used as argument for
 * the {@link GroovyASTTransformation} annotation.
 * @since 0.2.0
 */
public static void addASTAnnotationsFromTo(final ClassNode annotated, final CompilePhase compilePhase) {
  final AnnotationNode groovyAnn = getGroovyAnnotation(compilePhase);
  final AnnotationNode inheritConsAnn = getInheritConstructorsAnnotation();
  annotated.addAnnotation(inheritConsAnn);
  annotated.addAnnotation(groovyAnn);
}
origin: org.gcontracts/gcontracts-core

  private void markClassNodeAsContracted(final ClassNode classNode) {
    final ClassNode contractedAnnotationClassNode = ClassHelper.makeWithoutCaching(Contracted.class);

    if (classNode.getAnnotations(contractedAnnotationClassNode).isEmpty())
      classNode.addAnnotation(new AnnotationNode(contractedAnnotationClassNode));
  }
}
origin: org.kohsuke.droovy/groovy

private void setAnnotationMetaData(ClassNode cn) {
  Annotation[] annotations =  cn.getTypeClass().getAnnotations();
  for (int i=0; i<annotations.length; i++) {
    Annotation annotation = annotations[i];
    AnnotationNode node = new AnnotationNode(ClassHelper.make(annotation.annotationType()));
    configureAnnotation(node,annotation);
    cn.addAnnotation(node);
  }
}
origin: org.springframework.boot/spring-boot-cli

private void addEnableAutoConfigurationAnnotation(ClassNode classNode) {
  if (!hasEnableAutoConfigureAnnotation(classNode)) {
    AnnotationNode annotationNode = new AnnotationNode(
        ClassHelper.make("EnableAutoConfiguration"));
    classNode.addAnnotation(annotationNode);
  }
}
origin: io.ratpack/ratpack-groovy

 @Override
 public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
  if (staticCompile) {
   classNode.addAnnotation(new AnnotationNode(new ClassNode(CompileStatic.class)));
  }
  classNode.addAnnotation(new AnnotationNode(new ClassNode(InheritConstructors.class)));
  if (scriptPath != null) {
   AnnotationNode scriptPathAnnotation = new AnnotationNode(new ClassNode(ScriptPath.class));
   scriptPathAnnotation.addMember("value", new ConstantExpression(scriptPath.toUri().toString()));
   classNode.addAnnotation(scriptPathAnnotation);
  }
 }
});
origin: org.chromattic/chromattic.groovy

 public void applyGroovyInstrumentor(ClassNode classNode) {
  classNode.addAnnotation(new AnnotationNode(new ClassNode(GroovyInstrumentor.class)));
 }
}
origin: org.springframework.boot/spring-boot-cli

@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("SpringRunner")));
    classNode.addAnnotation(runWith);
  }
}
origin: org.codehaus.groovy/groovy-jdk14

private void setAnnotationMetaData(ClassNode cn) {
  Annotation[] annotations = cn.getTypeClass().getAnnotations();
  for (Annotation annotation : annotations) {
    AnnotationNode node = new AnnotationNode(ClassHelper.make(annotation.annotationType()));
    configureAnnotation(node, annotation);
    cn.addAnnotation(node);
  }
}
origin: org.springframework.boot/spring-boot-cli

/**
 * Add a single dependency with the specified classifier and type and, optionally, all
 * of its dependencies. The group ID and version of the dependency are resolved from
 * the module by using the customizer's {@link ArtifactCoordinatesResolver}.
 * @param module the module ID
 * @param classifier the classifier, may be {@code null}
 * @param type the type, may be {@code null}
 * @param transitive {@code true} if the transitive dependencies should also be added,
 * otherwise {@code false}
 * @return this {@link DependencyCustomizer} for continued use
 */
public DependencyCustomizer add(String module, String classifier, String type,
    boolean transitive) {
  if (canAdd()) {
    ArtifactCoordinatesResolver artifactCoordinatesResolver = this.dependencyResolutionContext
        .getArtifactCoordinatesResolver();
    this.classNode.addAnnotation(
        createGrabAnnotation(artifactCoordinatesResolver.getGroupId(module),
            artifactCoordinatesResolver.getArtifactId(module),
            artifactCoordinatesResolver.getVersion(module), classifier,
            type, transitive));
  }
  return this;
}
origin: com.cloudbees/groovy-cps

classNode.addAnnotation(new AnnotationNode(WORKFLOW_TRANSFORMED_TYPE));
origin: org.springframework.boot/spring-boot-cli

private void visitModule(ModuleNode module) {
  for (ClassNode classNode : module.getClasses()) {
    AnnotationNode annotation = new AnnotationNode(new ClassNode(Grab.class));
    annotation.addMember("value", new ConstantExpression("groovy"));
    classNode.addAnnotation(annotation);
    // We only need to do it at most once
    break;
  }
  // Disable the addition of a static initializer that calls Grape.addResolver
  // because all the dependencies are local now
  disableGrabResolvers(module.getClasses());
  disableGrabResolvers(module.getImports());
}
origin: dsyer/spring-boot-ratpack

@Override
public void visitBlockStatement(BlockStatement block) {
  if (block.isEmpty() || this.xformed) {
    return;
  }
  ClosureExpression closure = ratpack(block);
  if (closure != null) {
    this.classNode.addAnnotation(new AnnotationNode(ClassHelper
        .make("Component")));
    // Add a marker interface to the current script
    this.classNode.addInterface(ClassHelper.make(SOURCE_INTERFACE));
    // Implement the interface by adding a public read-only property with the
    // same name as the method in the interface (getRatpack). Make it return the
    // closure.
    this.classNode.addProperty(new PropertyNode(RATPACK, Modifier.PUBLIC
        | Modifier.FINAL, ClassHelper.CLOSURE_TYPE
        .getPlainNodeReference(), this.classNode, closure, null, null));
    // Only do this once per class
    this.xformed = true;
  }
}
org.codehaus.groovy.astClassNodeaddAnnotation

Popular methods of ClassNode

  • getName
  • getMethods
    This methods creates a list of all methods with this name of the current class and of all super clas
  • <init>
    Constructor used by makeArray() if no real class is available
  • getSuperClass
  • equals
  • addMethod
  • getAnnotations
  • addField
  • getFields
    Returns a list containing FieldNode objects for each field in the class represented by this ClassNod
  • getPlainNodeReference
  • getField
    Finds a field matching the given name in this class or a parent class.
  • getMethod
    Finds a method matching the given name and parameters in this class or any parent class.
  • getField,
  • getMethod,
  • isInterface,
  • getNameWithoutPackage,
  • isScript,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • setContentView (Activity)
  • addToBackStack (FragmentTransaction)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Path (java.nio.file)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now