mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 18:15:55 +00:00
[bugfix] mixing @Delegate and @Getter(lazy) causes positions to be lost. 15 years and nobody found this bug - not worth an issue or a changelog.
This commit is contained in:
1 parent
280d12c62d
commit
3022b26a9b
2 files changed
+17
-2
No files matched your search
@@ -218,7 +218,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
|
||||
|
||||
long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC);
|
||||
|
||||
injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source, lazy, onMethod));
|
||||
injectMethod(fieldNode.up(), source, createGetter(access, fieldNode, fieldNode.getTreeMaker(), source, lazy, onMethod));
|
||||
}
|
||||
|
||||
public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JavacNode source, boolean lazy, List<JCAnnotation> onMethod) {
|
||||
|
||||
@@ -1369,6 +1369,21 @@ public class JavacHandlerUtil {
|
||||
* Also takes care of updating the JavacAST.
|
||||
*/
|
||||
public static void injectMethod(JavacNode typeNode, JCMethodDecl method) {
|
||||
JavacNode source = typeNode.getNodeFor(getGeneratedBy(method));
|
||||
injectMethod(typeNode, source, method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given new method declaration to the provided type AST Node.
|
||||
* Can also inject constructors.
|
||||
*
|
||||
* Also takes care of updating the JavacAST.
|
||||
*
|
||||
* Ordinarily the 'source' is determined automatically. In rare cases generally involving combinations between
|
||||
* annotations, some of which require re-attribution such as {@code @Delegate}, that doesn't work. This method
|
||||
* exists if you explicitly have the source.
|
||||
*/
|
||||
public static void injectMethod(JavacNode typeNode, JavacNode source, JCMethodDecl method) {
|
||||
JCClassDecl type = (JCClassDecl) typeNode.get();
|
||||
|
||||
if (method.getName().contentEquals("<init>")) {
|
||||
@@ -1389,7 +1404,7 @@ public class JavacHandlerUtil {
|
||||
}
|
||||
|
||||
addSuppressWarningsAll(method.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(method)), typeNode.getContext());
|
||||
addGenerated(method.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(method)), typeNode.getContext());
|
||||
addGenerated(method.mods, typeNode, source, typeNode.getContext());
|
||||
type.defs = type.defs.append(method);
|
||||
|
||||
EnterReflect.memberEnter(method, typeNode);
|
||||
|
||||
Reference in new issue
Block a user