Interface RoundContext

All Known Subinterfaces:
RegistryRoundContext

public interface RoundContext
Context of a single round of code generation. For example the first round may generate types, that require additional code generation.
  • Method Details

    • availableAnnotations

      Collection<TypeName> availableAnnotations()
      Annotations available in this round, the collection contains only annotations valid for the extension being invoked.
      Returns:
      available annotations
    • types

      All types that are processed in this round. Only contains types that are valid for processing by this extension.
      Returns:
      matching types
    • annotatedTypes

      Collection<TypeInfo> annotatedTypes(TypeName annotationType)
      All types annotated with a specific annotation (including types that inherit such annotation from super types or through interfaces).
      Parameters:
      annotationType - annotation to check
      Returns:
      types that contain the annotation
    • annotatedAnnotations

      default Collection<TypeName> annotatedAnnotations(TypeName metaAnnotation)
      Annotation types present on wanted types, annotated with the specific "meta" annotation.
      Parameters:
      metaAnnotation - annotations annotated with the provided annotation
      Returns:
      annotation types
    • annotatedElements

      Collection<TypedElementInfo> annotatedElements(TypeName annotationType)
      All elements annotated with a specific annotation.
      Parameters:
      annotationType - annotation to check
      Returns:
      elements that contain the annotation
    • addGeneratedType

      void addGeneratedType(TypeName type, ClassModel.Builder newClass, TypeName mainTrigger, Object... originatingElements)
      Add a new class to be code generated.

      Actual code generation will be done once, at the end of this round. Note that you can always force immediate generation through CodegenContext.filer(). In such a case do not add the type through this method. If you call this method with a type that was already registered, you will replace that instance.

      Parameters:
      type - type of the new class
      newClass - builder of the new class
      mainTrigger - a type that caused this, may be the processor itself, if not bound to any type
      originatingElements - possible originating elements (such as Element in APT, or ClassInfo in classpath scanning)
    • generatedType

      Optional<ClassModel.Builder> generatedType(TypeName type)
      Class model builder for a type that is to be code generated. This method provides access to all types that are to be generated, even from other extensions that do not match annotations. Whether another extension was already called depends on its CodegenExtensionProvider weight. This method will return top level class model builder if the type represents an inner class of it.
      Parameters:
      type - type of the generated type
      Returns:
      class model of the new type if any
    • typeInfo

      Optional<TypeInfo> typeInfo(TypeName typeName)
      Discover information about the provided type.

      In case the type was generated by this processing round (even in another extension), the type info will reflect the current state of the class model builder that was registered with addGeneratedType(io.helidon.common.types.TypeName, io.helidon.codegen.classmodel.ClassModel.Builder, io.helidon.common.types.TypeName, Object...).

      Parameters:
      typeName - type name to discover
      Returns:
      discovered type information, or empty if the type cannot be discovered