Class ElementPrinterHelper

java.lang.Object
spoon.reflect.visitor.ElementPrinterHelper

public class ElementPrinterHelper extends Object
  • Constructor Details

  • Method Details

    • writeAnnotations

      public void writeAnnotations(CtElement element)
      Writes the annotations for the given element.
    • writeModifiers

      public void writeModifiers(CtModifiable modifiable)
      writes the modifiers of this modifiable in a specific order
    • visitCtNamedElement

      public void visitCtNamedElement(CtNamedElement namedElement, CtCompilationUnit sourceCompilationUnit)
    • writeExtendsClause

      public void writeExtendsClause(CtType<?> type)
    • writeImplementsClause

      public void writeImplementsClause(CtType<?> type)
      writes the implemented interfaces with a ListPrinter
    • writeExecutableParameters

      public void writeExecutableParameters(CtExecutable<?> executable)
    • writeThrowsClause

      public void writeThrowsClause(CtExecutable<?> executable)
      writes the thrown exception with a ListPrinter
    • writeStatement

      public void writeStatement(CtStatement statement)
      Writes a statement.
    • writeElementList

      public void writeElementList(List<CtTypeMember> elements)
      Writes a list of elements to the printer by using `scan` from the internal pretty-printer.
      Parameters:
      elements - List of elements to be written
    • writeAnnotationElement

      public void writeAnnotationElement(Factory factory, Object value)
      Writes an annotation element.
    • writeFormalTypeParameters

      public void writeFormalTypeParameters(CtFormalTypeDeclarer ctFormalTypeDeclarer)
      Writes formal type parameters given in parameter.
      Parameters:
      ctFormalTypeDeclarer - Reference with formal type arguments.
    • writeActualTypeArguments

      @Deprecated public void writeActualTypeArguments(CtActualTypeContainer ctGenericElementReference)
      Deprecated.
      use writeActualTypeArguments(CtActualTypeContainer, PrintTypeArguments). This method is only kept for backwards compatibility.
      Parameters:
      ctGenericElementReference - Reference with actual type arguments.
      See Also:
      writeActualTypeArguments(CtActualTypeContainer, PrintTypeArguments)
    • writeActualTypeArguments

      public void writeActualTypeArguments(CtActualTypeContainer ctGenericElementReference, ElementPrinterHelper.PrintTypeArguments handleImplicit)
      Writes actual type arguments in a CtActualTypeContainer element.
      Parameters:
      ctGenericElementReference - Reference with actual type arguments.
      handleImplicit - Whether to print type arguments if they are all implicit
    • writeImports

      public void writeImports(Collection<CtImport> imports)
      writes the imports in a specific order (eg all static imports together
    • writePackageLine

      public void writePackageLine(String packageQualifiedName)
      Write a package statement and a newline.
    • writePackageStatement

      public void writePackageStatement(String packageQualifiedName)
      Write a package statement.
    • writeComment

      public void writeComment(CtComment comment)
    • writeComment

      public void writeComment(CtElement element)
    • writeComment

      public void writeComment(CtElement element, CommentOffset offset)
    • getComments

      public List<CtComment> getComments(CtElement element, CommentOffset offset)
    • isElseIf

      public boolean isElseIf(CtIf ifStmt)
    • writeIfOrLoopBlock

      public void writeIfOrLoopBlock(CtStatement block)
      write all non-implicit parts of a block, with special care for indentation
    • writeQualifiedName

      public TokenWriter writeQualifiedName(String qualifiedName)
      splits qualified name to primitive tokens and sends them to TokenWriter individually
      Parameters:
      qualifiedName - to be sent qualified name
    • printList

      public <T> void printList(Iterable<T> iterable, String startKeyword, boolean startPrefixSpace, String start, boolean startSuffixSpace, boolean nextPrefixSpace, String next, boolean nextSuffixSpace, boolean endPrefixSpace, String end, Consumer<T> elementPrinter)
      Prints list of elements with defined delimiters using `printer`
      Parameters:
      iterable - the iterable of to be printed elements
      startKeyword - the optional start keyword. It is always printed if the value is not null
      startPrefixSpace - if true then `start` token is prefixed with space
      start - the string which has to be printed at the beginning of the list
      startSuffixSpace - if true then `start` token is suffixed with space
      nextPrefixSpace - if true then `next` token is prefixed with space
      next - the string which has to be used as separator before each next item
      nextSuffixSpace - if true then `next` token is suffixed with space
      endPrefixSpace - if true then `end` token is prefixed with space
      end - the string which has to be printed after the list
      elementPrinter - the Consumer, which is called once for each printer element of the `iterable`
    • printPermits

      protected void printPermits(CtSealable sealable)
      Prints the permits keyword followed by the permitted types of a CtSealable.

      If the given sealed type does not have any explicit permitted types, nothing is printed.

      Parameters:
      sealable - the sealed type to print the permitted types for.