diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2020-07-12 20:08:21 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2020-07-23 22:23:55 +0200 |
commit | b1f6372b358119309b26016317a6dd709b9daa13 (patch) | |
tree | 73c0222d4419221020285e2d6f8dc588e56a9933 /src/core/lombok/javac/handlers | |
parent | ce92389da76b17b2c8d9f8757d67b4ea3edc8cb5 (diff) | |
download | lombok-b1f6372b358119309b26016317a6dd709b9daa13.tar.gz lombok-b1f6372b358119309b26016317a6dd709b9daa13.tar.bz2 lombok-b1f6372b358119309b26016317a6dd709b9daa13.zip |
[fixes #2300] Keep method argument positions for lazy getter initializer
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleGetter.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 22f43d61..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,6 +270,11 @@ 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) { |