diff options
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleGetter.java')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleGetter.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 985873c1..110941d6 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -232,9 +232,17 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { List<JCStatement> statements; JCTree toClearOfMarkers = null; + int[] methodArgPos = null; boolean addSuppressWarningsUnchecked = false; if (lazy && !inNetbeansEditor(field)) { toClearOfMarkers = fieldNode.init; + if (toClearOfMarkers instanceof JCMethodInvocation) { + List<JCExpression> args = ((JCMethodInvocation) toClearOfMarkers).args; + methodArgPos = new int[args.length()]; + for (int i = 0; i < methodArgPos.length; i++) { + methodArgPos[i] = args.get(i).pos; + } + } statements = createLazyGetterBody(treeMaker, field, source); addSuppressWarningsUnchecked = LombokOptionsFactory.getDelombokOptions(field.getContext()).getFormatPreferences().generateSuppressWarnings(); } else { @@ -262,10 +270,20 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source, field.getContext()); if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null, null); + if (methodArgPos != null) { + for (int i = 0; i < methodArgPos.length; i++) { + ((JCMethodInvocation) toClearOfMarkers).args.get(i).pos = methodArgPos[i]; + } + } 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); |