aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/javac/JavacNode.java6
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java3
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java1
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java8
5 files changed, 16 insertions, 3 deletions
diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java
index a0ee2789..3d7ce73f 100644
--- a/src/core/lombok/javac/JavacNode.java
+++ b/src/core/lombok/javac/JavacNode.java
@@ -26,6 +26,7 @@ import java.util.List;
import javax.tools.Diagnostic;
import lombok.core.AST.Kind;
+import lombok.delombok.DeleteLombokAnnotations;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.tree.JCTree;
@@ -173,6 +174,11 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre
return ast.getContext();
}
+ public boolean shouldDeleteLombokAnnotations() {
+ DeleteLombokAnnotations dla = ast.getContext().get(DeleteLombokAnnotations.class);
+ return dla != null && dla.isDeleteLombokAnnotations();
+ }
+
/**
* Convenient shortcut to the owning JavacAST object's toName method.
*
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) {