diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2019-01-08 03:33:24 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2019-01-08 03:33:52 +0100 |
commit | ccfab5ebffbd14df59689b23ff6f3df52890dca8 (patch) | |
tree | 3022d684cae61f0fdb2d59856d72b677f0721a02 /src/core/lombok/javac/JavacAST.java | |
parent | 20df86149d3fe45a82d9b83e33b801f5dc7c34ca (diff) | |
download | lombok-ccfab5ebffbd14df59689b23ff6f3df52890dca8.tar.gz lombok-ccfab5ebffbd14df59689b23ff6f3df52890dca8.tar.bz2 lombok-ccfab5ebffbd14df59689b23ff6f3df52890dca8.zip |
[#1033] steps on the way to issue 1033: You can add cleanup tasks which are deferred (during the javac run) until the end.
This already fixes the exotic-to-the-point-of-nonexistent bug where setter and wither compete to steal the `@param` off of the field’s javadoc. Next are to fix builder and setter/wither competing whilst bringing javadocs to `@Builder`.
Then for various other conflicts, we should defer removal of lombok imports and annotations until the end too.
Diffstat (limited to 'src/core/lombok/javac/JavacAST.java')
-rw-r--r-- | src/core/lombok/javac/JavacAST.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index 9a5305a6..f2901038 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2018 The Project Lombok Authors. + * Copyright (C) 2009-2019 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -37,6 +37,8 @@ import javax.tools.JavaFileObject; import com.sun.tools.javac.util.JCDiagnostic; import lombok.core.AST; +import lombok.core.CleanupRegistry; +import lombok.core.CleanupTask; import lombok.permit.Permit; import com.sun.tools.javac.code.Source; @@ -65,6 +67,7 @@ import com.sun.tools.javac.util.Name; * something javac's own AST system does not offer. */ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { + private final CleanupRegistry cleanup; private final JavacElements elements; private final JavacTreeMaker treeMaker; private final Symtab symtab; @@ -80,7 +83,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { * @param context A Context object for interfacing with the compiler. * @param top The compilation unit, which serves as the top level node in the tree to be built. */ - public JavacAST(Messager messager, Context context, JCCompilationUnit top) { + public JavacAST(Messager messager, Context context, JCCompilationUnit top, CleanupRegistry cleanup) { super(sourceName(top), PackageName.getPackageName(top), new JavacImportList(top), statementTypes()); setTop(buildCompilationUnit(top)); this.context = context; @@ -90,6 +93,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { this.treeMaker = new JavacTreeMaker(TreeMaker.instance(context)); this.symtab = Symtab.instance(context); this.javacTypes = JavacTypes.instance(context); + this.cleanup = cleanup; clearChanged(); } @@ -140,6 +144,10 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { return Javac.getJavaCompilerVersion(); } + public void cleanupTask(String key, JCTree target, CleanupTask task) { + cleanup.registerTask(key, target, task); + } + /** @return A Name object generated for the proper name table belonging to this AST. */ public Name toName(String name) { return elements.getName(name); |