Package spoon.reflect.visitor
Class ElementPrinterHelper
java.lang.Object
spoon.reflect.visitor.ElementPrinterHelper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWhether to print generic types for references. -
Constructor Summary
ConstructorsConstructorDescriptionElementPrinterHelper(TokenWriter printerTokenWriter, DefaultJavaPrettyPrinter prettyPrinter, Environment env) -
Method Summary
Modifier and TypeMethodDescriptiongetComments(CtElement element, CommentOffset offset)boolean<T> voidprintList(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 voidprintPermits(CtSealable sealable)Prints thepermitskeyword followed by the permitted types of aCtSealable.voidvisitCtNamedElement(CtNamedElement namedElement, CtCompilationUnit sourceCompilationUnit)voidwriteActualTypeArguments(CtActualTypeContainer ctGenericElementReference)Deprecated.voidwriteActualTypeArguments(CtActualTypeContainer ctGenericElementReference, ElementPrinterHelper.PrintTypeArguments handleImplicit)Writes actual type arguments in aCtActualTypeContainerelement.voidwriteAnnotationElement(Factory factory, Object value)Writes an annotation element.voidwriteAnnotations(CtElement element)Writes the annotations for the given element.voidwriteComment(CtComment comment)voidwriteComment(CtElement element)voidwriteComment(CtElement element, CommentOffset offset)voidwriteElementList(List<CtTypeMember> elements)Writes a list of elements to the printer by using `scan` from the internal pretty-printer.voidwriteExecutableParameters(CtExecutable<?> executable)voidwriteExtendsClause(CtType<?> type)voidwriteFormalTypeParameters(CtFormalTypeDeclarer ctFormalTypeDeclarer)Writes formal type parameters given in parameter.voidwriteIfOrLoopBlock(CtStatement block)write all non-implicit parts of a block, with special care for indentationvoidwriteImplementsClause(CtType<?> type)writes the implemented interfaces with a ListPrintervoidwriteImports(Collection<CtImport> imports)writes the imports in a specific order (eg all static imports togethervoidwriteModifiers(CtModifiable modifiable)writes the modifiers of this modifiable in a specific ordervoidwritePackageLine(String packageQualifiedName)Write a package statement and a newline.voidwritePackageStatement(String packageQualifiedName)Write a package statement.writeQualifiedName(String qualifiedName)splits qualified name to primitive tokens and sends them to TokenWriter individuallyvoidwriteStatement(CtStatement statement)Writes a statement.voidwriteThrowsClause(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 aCtActualTypeContainerelement. 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 aCtActualTypeContainerelement.- 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 thepermitskeyword 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).