diff options
Diffstat (limited to 'src/core/lombok/javac/handlers')
4 files changed, 10 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index 4331761f..fe5f8566 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -58,6 +58,7 @@ public class HandleConstructor { public static class HandleNoArgsConstructor implements JavacAnnotationHandler<NoArgsConstructor> { @Override public boolean handle(AnnotationValues<NoArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) { markAnnotationAsProcessed(annotationNode, NoArgsConstructor.class); + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); JavacNode typeNode = annotationNode.up(); NoArgsConstructor ann = annotation.getInstance(); AccessLevel level = ann.access(); @@ -73,6 +74,7 @@ public class HandleConstructor { public static class HandleRequiredArgsConstructor implements JavacAnnotationHandler<RequiredArgsConstructor> { @Override public boolean handle(AnnotationValues<RequiredArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) { markAnnotationAsProcessed(annotationNode, RequiredArgsConstructor.class); + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); JavacNode typeNode = annotationNode.up(); RequiredArgsConstructor ann = annotation.getInstance(); AccessLevel level = ann.access(); @@ -102,6 +104,7 @@ public class HandleConstructor { public static class HandleAllArgsConstructor implements JavacAnnotationHandler<AllArgsConstructor> { @Override public boolean handle(AnnotationValues<AllArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) { markAnnotationAsProcessed(annotationNode, AllArgsConstructor.class); + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); JavacNode typeNode = annotationNode.up(); AllArgsConstructor ann = annotation.getInstance(); AccessLevel level = ann.access(); diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 16185e9c..9c0ce32f 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -95,6 +95,7 @@ public class HandleGetter implements JavacAnnotationHandler<Getter> { @Override public boolean handle(AnnotationValues<Getter> annotation, JCAnnotation ast, JavacNode annotationNode) { markAnnotationAsProcessed(annotationNode, Getter.class); + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); JavacNode node = annotationNode.up(); AccessLevel level = annotation.getInstance().value(); if (level == AccessLevel.NONE) return true; diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index a3822daa..dfc9c8ba 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -104,6 +104,7 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> { @Override public boolean handle(AnnotationValues<Setter> annotation, JCAnnotation ast, JavacNode annotationNode) { markAnnotationAsProcessed(annotationNode, Setter.class); + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); JavacNode node = annotationNode.up(); AccessLevel level = annotation.getInstance().value(); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index a4949a58..0df48358 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -92,13 +92,15 @@ public class JavacHandlerUtil { return; } - JCCompilationUnit unit = (JCCompilationUnit) annotation.top().get(); - deleteImportFromCompilationUnit(unit, annotationType.getName()); + deleteImportFromCompilationUnit(annotation, annotationType.getName()); } - private static void deleteImportFromCompilationUnit(JCCompilationUnit unit, String name) { + public static void deleteImportFromCompilationUnit(JavacNode node, String name) { + if (!node.shouldDeleteLombokAnnotations()) return; List<JCTree> newDefs = List.nil(); + JCCompilationUnit unit = (JCCompilationUnit) node.top().get(); + for (JCTree def : unit.defs) { boolean delete = false; if (def instanceof JCImport) { |