Package spoon.reflect.visitor
Interface PrettyPrinter
- All Known Implementing Classes:
DefaultJavaPrettyPrinter
,SniperJavaPrettyPrinter
public interface PrettyPrinter
This interface defines the pretty printers.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
calculate(CtCompilationUnit sourceCompilationUnit, List<CtType<?>> types)
Calculates the resulting source file for a list of types.Gets the line number mapping between the generated code and the original code.Gets the contents of the compilation unit.prettyprint(CtElement ctElement)
pretty-prints the element, call#toString()
to get the resultprintCompilationUnit(CtCompilationUnit compilationUnit)
Prints the compilation unit of module-info, package-info or types.printElement(CtElement element)
Prints an element.printModuleInfo(CtModule module)
Prints the module info.printPackageInfo(CtPackage pack)
Prints the package info.printTypes(CtType<?>... type)
Prints the types of one compilation unit It always resets the printing context at the beginning of this process.
-
Method Details
-
printCompilationUnit
Prints the compilation unit of module-info, package-info or types. -
printPackageInfo
Prints the package info. It always resets the printing context at the beginning of this process. -
printModuleInfo
Prints the module info. It always resets the printing context at the beginning of this process. -
printTypes
Prints the types of one compilation unit It always resets the printing context at the beginning of this process. -
printElement
Prints an element. This method shall be called by the toString() method of an element. It is responsible for any initialization required to print an arbitrary element.- Parameters:
element
-- Returns:
- A string containing the pretty printed element (and descendants).
-
getResult
String getResult()Gets the contents of the compilation unit. -
calculate
Calculates the resulting source file for a list of types. The source compilation unit is required for calculating the line numbers mapping. It always resets the printing context at the beginning of this process. -
getLineNumberMapping
Gets the line number mapping between the generated code and the original code. -
prettyprint
pretty-prints the element, call#toString()
to get the result
-