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
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidfinish()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 voidvisitServiceDescriptor(String type, String classname) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.voidvisitServiceDescriptor(String type, String classname, Element originatingElement) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ClassWriterOutputVisitor
getServiceEntries, visitClass, visitClass, visitGeneratedSourceFile, visitMetaInfFile, visitServiceDescriptor, visitServiceDescriptor
-
Constructor Details
-
InMemoryClassWriterOutputVisitor
- Parameters:
classLoader- The in-memory classloader
-
-
Method Details
-
visitClass
Description copied from interface:ClassWriterOutputVisitorVisits 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.AGGREGATINGvisitor from within theTypeElementVisitor.finish(io.micronaut.inject.visitor.VisitorContext)method. If the file- Specified by:
visitClassin interfaceClassWriterOutputVisitor- Parameters:
classname- the fully qualified classnameoriginatingElements- The originating elements- Returns:
- the output stream to write to
-
visitServiceDescriptor
Description copied from interface:ClassWriterOutputVisitorAllows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Specified by:
visitServiceDescriptorin interfaceClassWriterOutputVisitor- Parameters:
type- the fully qualified service nameclassname- the fully qualified classname
-
visitServiceDescriptor
Description copied from interface:ClassWriterOutputVisitorAllows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Specified by:
visitServiceDescriptorin interfaceClassWriterOutputVisitor- Parameters:
type- the fully qualified service nameclassname- the fully qualified classnameoriginatingElement- The originating element
-
visitMetaInfFile
Description copied from interface:ClassWriterOutputVisitorVisit a file within the META-INF directory of the 'classes' directory.- Specified by:
visitMetaInfFilein 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:ClassWriterOutputVisitorVisit a file that will be generated within the generated 'sources' directory.- Specified by:
visitGeneratedFilein interfaceClassWriterOutputVisitor- Parameters:
path- The path- Returns:
- The file if it was possible to create it
-
visitGeneratedFile
Description copied from interface:ClassWriterOutputVisitorVisit a file that will be generated within the generated 'sources' directory.- Specified by:
visitGeneratedFilein 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:ClassWriterOutputVisitorFinish writing and flush any service entries to disk.- Specified by:
finishin interfaceClassWriterOutputVisitor
-