mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 06:15:41 +00:00
Made 'printContent=true' work for types as well as method bodies/initializers.
This commit is contained in:
1 parent
21aa78996a
commit
bc44e76b7d
3 files changed
+18
-7
No files matched your search
@@ -42,9 +42,10 @@ public @interface PrintAST {
|
||||
String outfile() default "";
|
||||
|
||||
/**
|
||||
* Normally, the printer will print each node focusing on the node (E.g. classname, and such).
|
||||
* By setting printContent to true, methods, initializers, and other statement-containing elements
|
||||
* actually print their java code instead of a tree view of internal AST nodes.
|
||||
* Sets whether to print node structure (false) or generated java code (true).
|
||||
*
|
||||
* By setting printContent to true, the annotated element's java code representation is printed. If false,
|
||||
* its node structure (e.g. node classname) is printed, and this process is repeated for all children.
|
||||
*/
|
||||
boolean printContent() default false;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public interface EclipseASTVisitor {
|
||||
private int indent = 0;
|
||||
|
||||
/**
|
||||
* @param printContent if true, method and initializer bodies are printed directly, as java code,
|
||||
* @param printContent if true, bodies are printed directly, as java code,
|
||||
* instead of a tree listing of every AST node inside it.
|
||||
*/
|
||||
public Printer(boolean printContent) {
|
||||
@@ -122,7 +122,7 @@ public interface EclipseASTVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param printContent if true, method and initializer bodies are printed directly, as java code,
|
||||
* @param printContent if true, bodies are printed directly, as java code,
|
||||
* instead of a tree listing of every AST node inside it.
|
||||
* @param out write output to this stream. You must close it yourself. flush() is called after every line.
|
||||
*
|
||||
@@ -177,6 +177,10 @@ public interface EclipseASTVisitor {
|
||||
public void visitType(Node node, TypeDeclaration type) {
|
||||
print("<TYPE %s>", str(type.name));
|
||||
indent++;
|
||||
if ( printContent ) {
|
||||
print("%s", type);
|
||||
disablePrinting++;
|
||||
}
|
||||
}
|
||||
|
||||
public void visitAnnotationOnType(TypeDeclaration type, Node node, Annotation annotation) {
|
||||
@@ -184,6 +188,7 @@ public interface EclipseASTVisitor {
|
||||
}
|
||||
|
||||
public void endVisitType(Node node, TypeDeclaration type) {
|
||||
if ( printContent ) disablePrinting--;
|
||||
indent--;
|
||||
print("</TYPE %s>", str(type.name));
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public interface JavacASTVisitor {
|
||||
private int indent = 0;
|
||||
|
||||
/**
|
||||
* @param printContent if true, method and initializer bodies are printed directly, as java code,
|
||||
* @param printContent if true, bodies are printed directly, as java code,
|
||||
* instead of a tree listing of every AST node inside it.
|
||||
*/
|
||||
public Printer(boolean printContent) {
|
||||
@@ -112,7 +112,7 @@ public interface JavacASTVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param printContent if true, method and initializer bodies are printed directly, as java code,
|
||||
* @param printContent if true, bodies are printed directly, as java code,
|
||||
* instead of a tree listing of every AST node inside it.
|
||||
* @param out write output to this stream. You must close it yourself. flush() is called after every line.
|
||||
*
|
||||
@@ -149,6 +149,10 @@ public interface JavacASTVisitor {
|
||||
@Override public void visitType(Node node, JCClassDecl type) {
|
||||
print("<TYPE %s>", type.name);
|
||||
indent++;
|
||||
if ( printContent ) {
|
||||
print("%s", type);
|
||||
disablePrinting++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitAnnotationOnType(JCClassDecl type, Node node, JCAnnotation annotation) {
|
||||
@@ -156,6 +160,7 @@ public interface JavacASTVisitor {
|
||||
}
|
||||
|
||||
@Override public void endVisitType(Node node, JCClassDecl type) {
|
||||
if ( printContent ) disablePrinting--;
|
||||
indent--;
|
||||
print("</TYPE %s>", type.name);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user