aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-17 20:54:54 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-17 20:54:54 +0200
commit8aae52a9923c041486484d30b9b35ee9b6f2a8ea (patch)
treede2bec8feaa5e851acccb4276b9d433afc2fdbbc
parent5bdfa539f2f4277eda9ab414dab167a4d6d883e9 (diff)
downloadlombok-8aae52a9923c041486484d30b9b35ee9b6f2a8ea.tar.gz
lombok-8aae52a9923c041486484d30b9b35ee9b6f2a8ea.tar.bz2
lombok-8aae52a9923c041486484d30b9b35ee9b6f2a8ea.zip
A useful annotation that prints the AST of any annotated element via the XASTPrinters in each ASTVisitor interface.
-rw-r--r--src/lombok/core/PrintAST.java10
-rw-r--r--src/lombok/eclipse/handlers/HandlePrintAST.java17
-rw-r--r--src/lombok/javac/handlers/HandlePrintAST.java18
3 files changed, 45 insertions, 0 deletions
diff --git a/src/lombok/core/PrintAST.java b/src/lombok/core/PrintAST.java
new file mode 100644
index 00000000..3ad2bd68
--- /dev/null
+++ b/src/lombok/core/PrintAST.java
@@ -0,0 +1,10 @@
+package lombok.core;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.SOURCE)
+public @interface PrintAST {}
diff --git a/src/lombok/eclipse/handlers/HandlePrintAST.java b/src/lombok/eclipse/handlers/HandlePrintAST.java
new file mode 100644
index 00000000..2e379ce3
--- /dev/null
+++ b/src/lombok/eclipse/handlers/HandlePrintAST.java
@@ -0,0 +1,17 @@
+package lombok.eclipse.handlers;
+
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.mangosdk.spi.ProviderFor;
+
+import lombok.core.AnnotationValues;
+import lombok.core.PrintAST;
+import lombok.eclipse.EclipseASTVisitor;
+import lombok.eclipse.EclipseAnnotationHandler;
+import lombok.eclipse.EclipseAST.Node;
+
+@ProviderFor(EclipseAnnotationHandler.class)
+public class HandlePrintAST implements EclipseAnnotationHandler<PrintAST> {
+ @Override public void handle(AnnotationValues<PrintAST> annotation, Annotation ast, Node annotationNode) {
+ annotationNode.up().traverse(new EclipseASTVisitor.EclipseASTPrinter());
+ }
+}
diff --git a/src/lombok/javac/handlers/HandlePrintAST.java b/src/lombok/javac/handlers/HandlePrintAST.java
new file mode 100644
index 00000000..23f4c6d6
--- /dev/null
+++ b/src/lombok/javac/handlers/HandlePrintAST.java
@@ -0,0 +1,18 @@
+package lombok.javac.handlers;
+
+import org.mangosdk.spi.ProviderFor;
+
+import com.sun.tools.javac.tree.JCTree.JCAnnotation;
+
+import lombok.core.AnnotationValues;
+import lombok.core.PrintAST;
+import lombok.javac.JavacASTVisitor;
+import lombok.javac.JavacAnnotationHandler;
+import lombok.javac.JavacAST.Node;
+
+@ProviderFor(JavacAnnotationHandler.class)
+public class HandlePrintAST implements JavacAnnotationHandler<PrintAST> {
+ @Override public void handle(AnnotationValues<PrintAST> annotation, JCAnnotation ast, Node annotationNode) {
+ annotationNode.up().traverse(new JavacASTVisitor.JavacASTPrinter());
+ }
+}