Package io.micronaut.ast.groovy.utils
Class InMemoryClassWriterOutputVisitor
java.lang.Object
io.micronaut.ast.groovy.utils.InMemoryClassWriterOutputVisitor
- All Implemented Interfaces:
ClassWriterOutputVisitor
Utility class for testing Groovy visitors.
- Since:
- 3.0.0
- Author:
- graemerocher
-
Constructor Summary
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoid
finish()
Finish writing and flush any service entries to disk.visitClass
(String classname, Element... originatingElements) Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.visitGeneratedFile
(String path) Visit a file that will be generated within the generated 'sources' directory.visitGeneratedFile
(String path, Element... originatingElements) Visit a file that will be generated within the generated 'sources' directory.visitMetaInfFile
(String path, Element... originatingElements) Visit a file within the META-INF directory of the 'classes' directory.final void
visitServiceDescriptor
(String type, String classname) Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.void
visitServiceDescriptor
(String type, String classname, Element originatingElement) Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.inject.writer.ClassWriterOutputVisitor
getServiceEntries, visitClass, visitClass, visitGeneratedSourceFile, visitMetaInfFile, visitServiceDescriptor, visitServiceDescriptor
-
Constructor Details
-
InMemoryClassWriterOutputVisitor
- Parameters:
classLoader
- The in-memory classloader
-
-
Method Details
-
visitClass
Description copied from interface:ClassWriterOutputVisitor
Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.Note that this method should only be called from a
TypeElementVisitor.VisitorKind.AGGREGATING
visitor from within theTypeElementVisitor.finish(io.micronaut.inject.visitor.VisitorContext)
method. If the file- Specified by:
visitClass
in interfaceClassWriterOutputVisitor
- Parameters:
classname
- the fully qualified classnameoriginatingElements
- The originating elements- Returns:
- the output stream to write to
- Throws:
IOException
- if an error occurs creating the output stream
-
visitServiceDescriptor
Description copied from interface:ClassWriterOutputVisitor
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.- Specified by:
visitServiceDescriptor
in interfaceClassWriterOutputVisitor
- Parameters:
type
- the fully qualified service nameclassname
- the fully qualified classname
-
visitServiceDescriptor
Description copied from interface:ClassWriterOutputVisitor
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.- Specified by:
visitServiceDescriptor
in interfaceClassWriterOutputVisitor
- Parameters:
type
- the fully qualified service nameclassname
- the fully qualified classnameoriginatingElement
- The originating element
-
visitMetaInfFile
Description copied from interface:ClassWriterOutputVisitor
Visit a file within the META-INF directory of the 'classes' directory.- Specified by:
visitMetaInfFile
in interfaceClassWriterOutputVisitor
- Parameters:
path
- The path to the fileoriginatingElements
- The originating elements- Returns:
- An optional file it was possible to create it
-
visitGeneratedFile
Description copied from interface:ClassWriterOutputVisitor
Visit a file that will be generated within the generated 'sources' directory.- Specified by:
visitGeneratedFile
in interfaceClassWriterOutputVisitor
- Parameters:
path
- The path- Returns:
- The file if it was possible to create it
-
visitGeneratedFile
Description copied from interface:ClassWriterOutputVisitor
Visit a file that will be generated within the generated 'sources' directory.- Specified by:
visitGeneratedFile
in interfaceClassWriterOutputVisitor
- Parameters:
path
- The pathoriginatingElements
- the originating elements- Returns:
- The file if it was possible to create it
-
finish
public void finish()Description copied from interface:ClassWriterOutputVisitor
Finish writing and flush any service entries to disk.- Specified by:
finish
in interfaceClassWriterOutputVisitor
-