Class AbstractByteCodeGenerator
java.lang.Object
io.micronaut.sourcegen.generator.AbstractByteCodeGenerator
- All Implemented Interfaces:
SourceGenerator
- Direct Known Subclasses:
ByteCodeGenerator, ByteCodeGenerator
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 -
Method Summary
Modifier and TypeMethodDescriptionfinal voidwrite(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, boolean markAsGenerated, io.micronaut.inject.ast.Element... originatingElements) Write the file using the context.final voidwrite(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element... originatingElements) Write the file using the context.final voidWrite the source code.protected abstract booleanwriteClass(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, waitMethods inherited from interface SourceGenerator
getLanguage
-
Constructor Details
-
AbstractByteCodeGenerator
public AbstractByteCodeGenerator()
-
-
Method Details
-
write
Description copied from interface:SourceGeneratorWrite the source code.- Specified by:
writein interfaceSourceGenerator- Parameters:
objectDef- The object definitionwriter- 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:SourceGeneratorWrite the file using the context.- Specified by:
writein interfaceSourceGenerator- Parameters:
objectDef- The object to writecontext- The contextoriginatingElements- 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:SourceGeneratorWrite the file using the context.- Specified by:
writein interfaceSourceGenerator- Parameters:
objectDef- The object to writecontext- The contextmarkAsGenerated- Whether to annotate the written types withGeneratedSourceoriginatingElements- 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 definitionouterType- The enclosing type, ornullcontext- The visitor contextoriginatingElements- Originating elements- Returns:
truewhen member definitions should be traversed- Throws:
Exception- If emission fails
-