diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-08-27 23:16:47 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-08-27 23:16:47 +0200 |
commit | 4e152f2f1485f904feb45ae614236d4aa4b6edc9 (patch) | |
tree | aa7de35a215a5d7077e27e0ef4c1699e9c56779b /src/lombok/eclipse/handlers/HandleGetter.java | |
parent | 0221e460b2e648b142284c6c462d5798f33a3ff7 (diff) | |
parent | fe0da3f53f1e88b704e21463cc5fea3d998e394a (diff) | |
download | lombok-4e152f2f1485f904feb45ae614236d4aa4b6edc9.tar.gz lombok-4e152f2f1485f904feb45ae614236d4aa4b6edc9.tar.bz2 lombok-4e152f2f1485f904feb45ae614236d4aa4b6edc9.zip |
Merge branch 'nonnull'
Conflicts:
src/lombok/eclipse/handlers/HandleData.java
src/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
src/lombok/eclipse/handlers/HandleSetter.java
src/lombok/javac/handlers/HandleData.java
src/lombok/javac/handlers/HandleEqualsAndHashCode.java
src/lombok/javac/handlers/HandleSetter.java
Diffstat (limited to 'src/lombok/eclipse/handlers/HandleGetter.java')
-rw-r--r-- | src/lombok/eclipse/handlers/HandleGetter.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lombok/eclipse/handlers/HandleGetter.java b/src/lombok/eclipse/handlers/HandleGetter.java index 982ccc97..5fb7876a 100644 --- a/src/lombok/eclipse/handlers/HandleGetter.java +++ b/src/lombok/eclipse/handlers/HandleGetter.java @@ -27,7 +27,7 @@ import lombok.Getter; import lombok.core.AnnotationValues; import lombok.core.TransformationsUtil; import lombok.core.AST.Kind; -import lombok.eclipse.Eclipse; +import static lombok.eclipse.Eclipse.*; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseAST.Node; @@ -64,7 +64,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> { public void generateGetterForField(Node fieldNode, ASTNode pos) { for ( Node child : fieldNode.down() ) { if ( child.getKind() == Kind.ANNOTATION ) { - if ( Eclipse.annotationTypeMatches(Getter.class, child) ) { + if ( annotationTypeMatches(Getter.class, child) ) { //The annotation will make it happen, so we can skip it. return; } @@ -87,7 +87,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> { } FieldDeclaration field = (FieldDeclaration) fieldNode.get(); - TypeReference fieldType = Eclipse.copyType(field.type); + TypeReference fieldType = copyType(field.type); String fieldName = new String(field.name); boolean isBoolean = nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0; String getterName = TransformationsUtil.toGetterName(fieldName, isBoolean); @@ -113,6 +113,11 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> { } MethodDeclaration method = generateGetter((TypeDeclaration) fieldNode.up().get(), field, getterName, modifier, pos); + Annotation[] copiedAnnotations = copyAnnotations( + findAnnotations(field, NON_NULL_PATTERN), findAnnotations(field, NULLABLE_PATTERN)); + if (copiedAnnotations.length != 0) { + method.annotations = copiedAnnotations; + } injectMethod(fieldNode.up(), method); @@ -123,14 +128,14 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> { int modifier, ASTNode pos) { MethodDeclaration method = new MethodDeclaration(parent.compilationResult); method.modifiers = modifier; - method.returnType = Eclipse.copyType(field.type); + method.returnType = copyType(field.type); method.annotations = null; method.arguments = null; method.selector = name.toCharArray(); method.binding = null; method.thrownExceptions = null; method.typeParameters = null; - method.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; + method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; Expression fieldExpression = new SingleNameReference(field.name, (field.declarationSourceStart << 32) | field.declarationSourceEnd); Statement returnStatement = new ReturnStatement(fieldExpression, field.sourceStart, field.sourceEnd); method.bodyStart = method.declarationSourceStart = method.sourceStart = pos.sourceStart; |