aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java7
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java20
2 files changed, 17 insertions, 10 deletions
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java
index 985873c1..22f43d61 100644
--- a/src/core/lombok/javac/handlers/HandleGetter.java
+++ b/src/core/lombok/javac/handlers/HandleGetter.java
@@ -265,7 +265,12 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
decl.mods.annotations = decl.mods.annotations.appendList(delegates);
if (addSuppressWarningsUnchecked) {
- addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), List.<JCExpression>of(treeMaker.Literal("all"), treeMaker.Literal("unchecked"))));
+ ListBuffer<JCExpression> suppressions = new ListBuffer<JCExpression>();
+ if (!Boolean.FALSE.equals(field.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS))) {
+ suppressions.add(treeMaker.Literal("all"));
+ }
+ suppressions.add(treeMaker.Literal("unchecked"));
+ addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), suppressions.toList()));
}
copyJavadoc(field, decl, CopyJavadoc.GETTER);
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index e0f6276f..3655e680 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1277,15 +1277,17 @@ public class JavacHandlerUtil {
public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return;
- boolean addJLSuppress = true;
-
- for (JCAnnotation ann : mods.annotations) {
- JCTree type = ann.getAnnotationType();
- Name n = null;
- if (type instanceof JCIdent) n = ((JCIdent) type).name;
- else if (type instanceof JCFieldAccess) n = ((JCFieldAccess) type).name;
- if (n != null && n.contentEquals("SuppressWarnings")) {
- addJLSuppress = false;
+ boolean addJLSuppress = !Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS));
+
+ if (addJLSuppress) {
+ for (JCAnnotation ann : mods.annotations) {
+ JCTree type = ann.getAnnotationType();
+ Name n = null;
+ if (type instanceof JCIdent) n = ((JCIdent) type).name;
+ else if (type instanceof JCFieldAccess) n = ((JCFieldAccess) type).name;
+ if (n != null && n.contentEquals("SuppressWarnings")) {
+ addJLSuppress = false;
+ }
}
}
if (addJLSuppress) addAnnotation(mods, node, pos, source, context, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all"));