aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/JavacASTVisitor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/lombok/javac/JavacASTVisitor.java')
-rw-r--r--src/lombok/javac/JavacASTVisitor.java45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/lombok/javac/JavacASTVisitor.java b/src/lombok/javac/JavacASTVisitor.java
index 15d848dd..ac953974 100644
--- a/src/lombok/javac/JavacASTVisitor.java
+++ b/src/lombok/javac/JavacASTVisitor.java
@@ -1,7 +1,26 @@
+/*
+ * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package lombok.javac;
-import java.io.File;
-import java.io.FileNotFoundException;
import java.io.PrintStream;
import lombok.javac.JavacAST.Node;
@@ -15,6 +34,10 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+/**
+ * Implement so you can ask any JavacAST.Node to traverse depth-first through all children,
+ * calling the appropriate visit and endVisit methods.
+ */
public interface JavacASTVisitor {
/**
* Called at the very beginning and end.
@@ -71,20 +94,30 @@ public interface JavacASTVisitor {
void visitStatement(Node statementNode, JCTree statement);
void endVisitStatement(Node statementNode, JCTree statement);
+ /**
+ * Prints the structure of an AST.
+ */
public static class Printer implements JavacASTVisitor {
private final PrintStream out;
private final boolean printContent;
private int disablePrinting = 0;
private int indent = 0;
+ /**
+ * @param printContent if true, method and initializer bodies are printed directly, as java code,
+ * instead of a tree listing of every AST node inside it.
+ */
public Printer(boolean printContent) {
this(printContent, System.out);
}
- public Printer(boolean printContent, File file) throws FileNotFoundException {
- this(printContent, new PrintStream(file));
- }
-
+ /**
+ * @param printContent if true, method and initializer bodies are printed directly, as java code,
+ * instead of a tree listing of every AST node inside it.
+ * @param PrintStream write output to this stream. You must close it yourself. flush() is called after every line.
+ *
+ * @see java.io.PrintStream#flush()
+ */
public Printer(boolean printContent, PrintStream out) {
this.printContent = printContent;
this.out = out;