diff options
Diffstat (limited to 'src/core/lombok/eclipse/handlers')
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 12 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleGetter.java | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 4cf64a14..b0b88656 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -774,9 +774,19 @@ public class EclipseHandlerUtil { } } + private static final Map<FieldDeclaration, GetterMethod> generatedLazyGetters = new WeakHashMap<FieldDeclaration, GetterMethod>(); + + static void registerCreatedLazyGetter(FieldDeclaration field, char[] methodName, TypeReference returnType) { + generatedLazyGetters.put(field, new GetterMethod(methodName, returnType)); + } + private static GetterMethod findGetter(EclipseNode field) { - TypeReference fieldType = ((FieldDeclaration)field.get()).type; + FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get(); + GetterMethod gm = generatedLazyGetters.get(fieldDeclaration); + if (gm != null) return gm; + TypeReference fieldType = fieldDeclaration.type; boolean isBoolean = nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0; + EclipseNode typeNode = field.up(); for (String potentialGetterName : toAllGetterNames(field, isBoolean)) { for (EclipseNode potentialGetter : typeNode.down()) { diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index d53bf89b..31376749 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -268,6 +268,9 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart; method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd; method.statements = statements; + + EclipseHandlerUtil.registerCreatedLazyGetter((FieldDeclaration) fieldNode.get(), method.selector, returnType); + return method; } |