public class ElementPrinterHelper
extends java.lang.Object
Constructor and Description |
---|
ElementPrinterHelper(TokenWriter printerTokenWriter,
DefaultJavaPrettyPrinter prettyPrinter,
Environment env) |
Modifier and Type | Method and Description |
---|---|
java.util.List<CtComment> |
getComments(CtElement element,
CommentOffset offset) |
boolean |
isElseIf(CtIf ifStmt) |
<T> void |
printList(java.lang.Iterable<T> iterable,
java.lang.String startKeyword,
boolean startPrefixSpace,
java.lang.String start,
boolean startSuffixSpace,
boolean nextPrefixSpace,
java.lang.String next,
boolean nextSuffixSpace,
boolean endPrefixSpace,
java.lang.String end,
java.util.function.Consumer<T> elementPrinter)
Prints list of elements with defined delimiters using `printer`
|
void |
visitCtNamedElement(CtNamedElement namedElement,
CtCompilationUnit sourceCompilationUnit) |
void |
writeActualTypeArguments(CtActualTypeContainer ctGenericElementReference)
Writes actual type arguments in a
CtActualTypeContainer element. |
void |
writeAnnotationElement(Factory factory,
java.lang.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(java.util.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 indentation
|
void |
writeImplementsClause(CtType<?> type)
writes the implemented interfaces with a ListPrinter
|
void |
writeImports(java.util.Collection<CtImport> imports)
writes the imports in a specific order (eg all static imports together
|
void |
writeModifiers(CtModifiable modifiable)
writes the modifiers of this modifiable in a specific order
|
void |
writePackageLine(java.lang.String packageQualifiedName)
Write a package statement and a newline.
|
void |
writePackageStatement(java.lang.String packageQualifiedName)
Write a package statement.
|
TokenWriter |
writeQualifiedName(java.lang.String qualifiedName)
splits qualified name to primitive tokens and sends them to TokenWriter individually
|
void |
writeStatement(CtStatement statement)
Writes a statement.
|
void |
writeThrowsClause(CtExecutable<?> executable)
writes the thrown exception with a ListPrinter
|
public ElementPrinterHelper(TokenWriter printerTokenWriter, DefaultJavaPrettyPrinter prettyPrinter, Environment env)
public void writeAnnotations(CtElement element)
public void writeModifiers(CtModifiable modifiable)
public void visitCtNamedElement(CtNamedElement namedElement, CtCompilationUnit sourceCompilationUnit)
public void writeExtendsClause(CtType<?> type)
public void writeImplementsClause(CtType<?> type)
public void writeExecutableParameters(CtExecutable<?> executable)
public void writeThrowsClause(CtExecutable<?> executable)
public void writeStatement(CtStatement statement)
public void writeElementList(java.util.List<CtTypeMember> elements)
elements
- List of elements to be writtenpublic void writeAnnotationElement(Factory factory, java.lang.Object value)
public void writeFormalTypeParameters(CtFormalTypeDeclarer ctFormalTypeDeclarer)
ctFormalTypeDeclarer
- Reference with formal type arguments.public void writeActualTypeArguments(CtActualTypeContainer ctGenericElementReference)
CtActualTypeContainer
element.ctGenericElementReference
- Reference with actual type arguments.public void writeImports(java.util.Collection<CtImport> imports)
public void writePackageLine(java.lang.String packageQualifiedName)
public void writePackageStatement(java.lang.String packageQualifiedName)
public void writeComment(CtComment comment)
public void writeComment(CtElement element)
public void writeComment(CtElement element, CommentOffset offset)
public java.util.List<CtComment> getComments(CtElement element, CommentOffset offset)
public boolean isElseIf(CtIf ifStmt)
public void writeIfOrLoopBlock(CtStatement block)
public TokenWriter writeQualifiedName(java.lang.String qualifiedName)
qualifiedName
- to be sent qualified namepublic <T> void printList(java.lang.Iterable<T> iterable, java.lang.String startKeyword, boolean startPrefixSpace, java.lang.String start, boolean startSuffixSpace, boolean nextPrefixSpace, java.lang.String next, boolean nextSuffixSpace, boolean endPrefixSpace, java.lang.String end, java.util.function.Consumer<T> elementPrinter)
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
- the Consumer
, which is called once for each printer element of the `iterable`Copyright © 2007–2021 Inria. All rights reserved.