mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 14:16:11 +00:00
A useful annotation that prints the AST of any annotated element via the XASTPrinters in each ASTVisitor interface.
This commit is contained in:
1 parent
5bdfa539f2
commit
8aae52a992
3 files changed
+45
No files matched your search
@@ -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 {}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user