diff options
author | Roel Spilker <r.spilker@gmail.com> | 2012-06-18 23:37:34 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2012-06-18 23:38:02 +0200 |
commit | 37cbe2d3f9cd8737b46b6bfb263277f7b7cd7861 (patch) | |
tree | c8f5f66c3b420bbc1beecb85fd5a67905c5a54d3 /src/core/lombok | |
parent | 78bf0f6fbbba39e1c56d5dda3df7b0c3eaec74ad (diff) | |
download | lombok-37cbe2d3f9cd8737b46b6bfb263277f7b7cd7861.tar.gz lombok-37cbe2d3f9cd8737b46b6bfb263277f7b7cd7861.tar.bz2 lombok-37cbe2d3f9cd8737b46b6bfb263277f7b7cd7861.zip |
Fix for issue 376 for Eclipse
Diffstat (limited to 'src/core/lombok')
-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; } |