Package spoon.reflect.visitor
Class ElementPrinterHelper
java.lang.Object
spoon.reflect.visitor.ElementPrinterHelper
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Whether to print generic types for references. -
Constructor Summary
ConstructorDescriptionElementPrinterHelper(TokenWriter printerTokenWriter, DefaultJavaPrettyPrinter prettyPrinter, Environment env)
-
Method Summary
Modifier and TypeMethodDescriptiongetComments(CtElement element, CommentOffset offset)
boolean
<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`protected void
printPermits(CtSealable sealable)
Prints thepermits
keyword followed by the permitted types of aCtSealable
.void
visitCtNamedElement(CtNamedElement namedElement, CtCompilationUnit sourceCompilationUnit)
void
writeActualTypeArguments(CtActualTypeContainer ctGenericElementReference)
Deprecated.void
writeActualTypeArguments(CtActualTypeContainer ctGenericElementReference, ElementPrinterHelper.PrintTypeArguments handleImplicit)
Writes actual type arguments in aCtActualTypeContainer
element.void
writeAnnotationElement(Factory factory, Object value)
Writes an annotation element.void
writeAnnotations(CtElement element)
Writes the annotations for the given element.void
writeComment(CtComment comment)
void
writeComment(CtElement element)
void
writeComment(CtElement element, CommentOffset offset)
void
writeElementList(List<CtTypeMember> elements)
Writes a list of elements to the printer by using `scan` from the internal pretty-printer.void
writeExecutableParameters(CtExecutable<?> executable)
void
writeExtendsClause(CtType<?> type)
void
writeFormalTypeParameters(CtFormalTypeDeclarer ctFormalTypeDeclarer)
Writes formal type parameters given in parameter.void
writeIfOrLoopBlock(CtStatement block)
write all non-implicit parts of a block, with special care for indentationvoid
writeImplementsClause(CtType<?> type)
writes the implemented interfaces with a ListPrintervoid
writeImports(Collection<CtImport> imports)
writes the imports in a specific order (eg all static imports togethervoid
writeModifiers(CtModifiable modifiable)
writes the modifiers of this modifiable in a specific ordervoid
writePackageLine(String packageQualifiedName)
Write a package statement and a newline.void
writePackageStatement(String packageQualifiedName)
Write a package statement.writeQualifiedName(String qualifiedName)
splits qualified name to primitive tokens and sends them to TokenWriter individuallyvoid
writeStatement(CtStatement statement)
Writes a statement.void
writeThrowsClause(CtExecutable<?> executable)
writes the thrown exception with a ListPrinter
-
Constructor Details
-
ElementPrinterHelper
public ElementPrinterHelper(TokenWriter printerTokenWriter, DefaultJavaPrettyPrinter prettyPrinter, Environment env)
-
-
Method Details
-
writeAnnotations
Writes the annotations for the given element. -
writeModifiers
writes the modifiers of this modifiable in a specific order -
visitCtNamedElement
public void visitCtNamedElement(CtNamedElement namedElement, CtCompilationUnit sourceCompilationUnit) -
writeExtendsClause
-
writeImplementsClause
writes the implemented interfaces with a ListPrinter -
writeExecutableParameters
-
writeThrowsClause
writes the thrown exception with a ListPrinter -
writeStatement
Writes a statement. -
writeElementList
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
Writes an annotation element. -
writeFormalTypeParameters
Writes formal type parameters given in parameter.- Parameters:
ctFormalTypeDeclarer
- Reference with formal type arguments.
-
writeActualTypeArguments
Deprecated.usewriteActualTypeArguments(CtActualTypeContainer, PrintTypeArguments)
. This method is only kept for backwards compatibility.Writes actual type arguments in aCtActualTypeContainer
element. PassesElementPrinterHelper.PrintTypeArguments.ONLY_PRINT_EXPLICIT_TYPES
.- 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 aCtActualTypeContainer
element.- Parameters:
ctGenericElementReference
- Reference with actual type arguments.handleImplicit
- Whether to print type arguments if they are all implicit
-
writeImports
writes the imports in a specific order (eg all static imports together -
writePackageLine
Write a package statement and a newline. -
writePackageStatement
Write a package statement. -
writeComment
-
writeComment
-
writeComment
-
getComments
-
isElseIf
-
writeIfOrLoopBlock
write all non-implicit parts of a block, with special care for indentation -
writeQualifiedName
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 elementsstartKeyword
- the optional start keyword. It is always printed if the value is not nullstartPrefixSpace
- if true then `start` token is prefixed with spacestart
- the string which has to be printed at the beginning of the liststartSuffixSpace
- if true then `start` token is suffixed with spacenextPrefixSpace
- if true then `next` token is prefixed with spacenext
- the string which has to be used as separator before each next itemnextSuffixSpace
- if true then `next` token is suffixed with spaceendPrefixSpace
- if true then `end` token is prefixed with spaceend
- the string which has to be printed after the listelementPrinter
- theConsumer
, which is called once for each printer element of the `iterable`
-
printPermits
Prints thepermits
keyword followed by the permitted types of aCtSealable
.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.
-
writeActualTypeArguments(CtActualTypeContainer, PrintTypeArguments)
.