Interface PrettyPrinter

All Known Implementing Classes:
DefaultJavaPrettyPrinter, SniperJavaPrettyPrinter

public interface PrettyPrinter
This interface defines the pretty printers.
  • Method Details

    • printCompilationUnit

      String printCompilationUnit(CtCompilationUnit compilationUnit)
      Prints the compilation unit of module-info, package-info or types.
    • printPackageInfo

      String printPackageInfo(CtPackage pack)
      Prints the package info. It always resets the printing context at the beginning of this process.
    • printModuleInfo

      String printModuleInfo(CtModule module)
      Prints the module info. It always resets the printing context at the beginning of this process.
    • printTypes

      String printTypes(CtType<?>... type)
      Prints the types of one compilation unit It always resets the printing context at the beginning of this process.
    • printElement

      String printElement(CtElement element)
      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

      void calculate(CtCompilationUnit sourceCompilationUnit, List<CtType<?>> types)
      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

      Map<Integer,​Integer> getLineNumberMapping()
      Gets the line number mapping between the generated code and the original code.
    • prettyprint

      String prettyprint(CtElement ctElement)
      pretty-prints the element, call #toString() to get the result