diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-03-22 11:42:09 +0100 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-03-22 11:42:09 +0100 |
commit | 5e2a90836d0c332b75af15b8f42403cf799ec355 (patch) | |
tree | e86dea771659848445db98bed7fd3889d6ae33b9 /src/core/lombok/javac/handlers | |
parent | 3400f66fa70da6664e91d98cc63d8ea959979606 (diff) | |
download | lombok-5e2a90836d0c332b75af15b8f42403cf799ec355.tar.gz lombok-5e2a90836d0c332b75af15b8f42403cf799ec355.tar.bz2 lombok-5e2a90836d0c332b75af15b8f42403cf799ec355.zip |
[javac] defer removal of `import lombok.x;` nodes until delombok
Our test harness setup for JDK15 and up doesn't work with annotations on record 'fields' (`record X(@RightHere String foo)`).
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index b4f2acc4..ac00fb1f 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -103,6 +103,7 @@ import lombok.delombok.LombokOptionsFactory; import lombok.experimental.Accessors; import lombok.experimental.Tolerate; import lombok.javac.Javac; +import lombok.javac.JavacAugments; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; import lombok.permit.Permit; @@ -537,21 +538,18 @@ public class JavacHandlerUtil { public static void deleteImportFromCompilationUnit(JavacNode node, String name) { if (inNetbeansEditor(node)) return; if (!node.shouldDeleteLombokAnnotations()) return; - ListBuffer<JCTree> newDefs = new ListBuffer<JCTree>(); JCCompilationUnit unit = (JCCompilationUnit) node.top().get(); for (JCTree def : unit.defs) { - boolean delete = false; - if (def instanceof JCImport) { - JCImport imp0rt = (JCImport)def; - delete = (!imp0rt.staticImport && imp0rt.qualid.toString().equals(name)); - } - if (!delete) newDefs.append(def); + if (!(def instanceof JCImport)) continue; + JCImport imp0rt = (JCImport) def; + if (imp0rt.staticImport) continue; + if (!imp0rt.qualid.toString().equals(name)) continue; + JavacAugments.JCImport_deletable.set(imp0rt, true); } - unit.defs = newDefs.toList(); } - + private static List<JCAnnotation> filterList(List<JCAnnotation> annotations, JCTree jcTree) { ListBuffer<JCAnnotation> newAnnotations = new ListBuffer<JCAnnotation>(); for (JCAnnotation ann : annotations) { |