Class AbstractByteCodeGenerator

java.lang.Object
io.micronaut.sourcegen.generator.AbstractByteCodeGenerator
All Implemented Interfaces:
SourceGenerator
Direct Known Subclasses:
ByteCodeGenerator, ByteCodeGenerator

@Internal public abstract class AbstractByteCodeGenerator extends Object implements SourceGenerator
Common class-output and member-type traversal for bytecode generators.

A backend returns whether it emitted the definition itself. A source fallback can return false when its source already contains member types; this prevents those types from being emitted a second time by the traversal.

Since:
2.2
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    write(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, boolean markAsGenerated, io.micronaut.inject.ast.Element... originatingElements)
    Write the file using the context.
    final void
    write(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element... originatingElements)
    Write the file using the context.
    final void
    write(ObjectDef objectDef, Writer writer)
    Write the source code.
    protected abstract boolean
    writeClass(ObjectDef objectDef, @Nullable ClassTypeDef outerType, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element[] originatingElements)
    Emit one definition.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface SourceGenerator

    getLanguage
  • Constructor Details

    • AbstractByteCodeGenerator

      public AbstractByteCodeGenerator()
  • Method Details

    • write

      public final void write(ObjectDef objectDef, Writer writer)
      Description copied from interface: SourceGenerator
      Write the source code.
      Specified by:
      write in interface SourceGenerator
      Parameters:
      objectDef - The object definition
      writer - The writer
    • write

      public final void write(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element... originatingElements)
      Description copied from interface: SourceGenerator
      Write the file using the context.
      Specified by:
      write in interface SourceGenerator
      Parameters:
      objectDef - The object to write
      context - The context
      originatingElements - the originated elements
    • write

      public final void write(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, boolean markAsGenerated, io.micronaut.inject.ast.Element... originatingElements)
      Description copied from interface: SourceGenerator
      Write the file using the context.
      Specified by:
      write in interface SourceGenerator
      Parameters:
      objectDef - The object to write
      context - The context
      markAsGenerated - Whether to annotate the written types with GeneratedSource
      originatingElements - the originated elements
    • writeClass

      protected abstract boolean writeClass(ObjectDef objectDef, @Nullable ClassTypeDef outerType, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element[] originatingElements) throws Exception
      Emit one definition.
      Parameters:
      objectDef - The definition
      outerType - The enclosing type, or null
      context - The visitor context
      originatingElements - Originating elements
      Returns:
      true when member definitions should be traversed
      Throws:
      Exception - If emission fails