mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-18 22:13:28 +00:00
More fixes to avoid erroneous "getter/setter is already there, not generating it" warnings
when the getter/setter already there was in fact generated by lombok, and fixed a bug in eclipse where a boolean array's getter method would be called isFoo() instead of getFoo().
This commit is contained in:
1 parent
12d44e59c5
commit
5fef32c1f5
4 files changed
+13
-41
No files matched your search
@@ -62,23 +62,16 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
|
||||
* be a warning if its already there. The default access level is used.
|
||||
*/
|
||||
public void generateGetterForField(Node fieldNode, ASTNode pos) {
|
||||
AccessLevel level = AccessLevel.PUBLIC;
|
||||
Node errorNode = fieldNode;
|
||||
boolean whineIfExists = false;
|
||||
|
||||
for ( Node child : fieldNode.down() ) {
|
||||
if ( child.getKind() == Kind.ANNOTATION ) {
|
||||
if ( Eclipse.annotationTypeMatches(Getter.class, child) ) {
|
||||
level = Eclipse.createAnnotation(Getter.class, child).getInstance().value();
|
||||
errorNode = child;
|
||||
pos = child.get();
|
||||
whineIfExists = true;
|
||||
break;
|
||||
//The annotation will make it happen, so we can skip it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createGetterForField(level, fieldNode, errorNode, pos, whineIfExists);
|
||||
createGetterForField(AccessLevel.PUBLIC, fieldNode, fieldNode, pos, false);
|
||||
}
|
||||
|
||||
public boolean handle(AnnotationValues<Getter> annotation, Annotation ast, Node annotationNode) {
|
||||
@@ -96,7 +89,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
|
||||
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
|
||||
TypeReference fieldType = Eclipse.copyType(field.type);
|
||||
String getterName = TransformationsUtil.toGetterName(
|
||||
new String(field.name), nameEquals(fieldType.getTypeName(), "boolean"));
|
||||
new String(field.name), nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0);
|
||||
|
||||
int modifier = toModifier(level) | (field.modifiers & ClassFileConstants.AccStatic);
|
||||
|
||||
|
||||
@@ -66,23 +66,16 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
|
||||
* be a warning if its already there. The default access level is used.
|
||||
*/
|
||||
public void generateSetterForField(Node fieldNode, ASTNode pos) {
|
||||
AccessLevel level = AccessLevel.PUBLIC;
|
||||
Node errorNode = fieldNode;
|
||||
boolean whineIfExists = false;
|
||||
|
||||
for ( Node child : fieldNode.down() ) {
|
||||
if ( child.getKind() == Kind.ANNOTATION ) {
|
||||
if ( Eclipse.annotationTypeMatches(Setter.class, child) ) {
|
||||
level = Eclipse.createAnnotation(Setter.class, child).getInstance().value();
|
||||
errorNode = child;
|
||||
pos = child.get();
|
||||
whineIfExists = true;
|
||||
break;
|
||||
//The annotation will make it happen, so we can skip it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createSetterForField(level, fieldNode, errorNode, pos, whineIfExists);
|
||||
createSetterForField(AccessLevel.PUBLIC, fieldNode, fieldNode, pos, false);
|
||||
}
|
||||
|
||||
public boolean handle(AnnotationValues<Setter> annotation, Annotation ast, Node annotationNode) {
|
||||
|
||||
@@ -63,23 +63,16 @@ public class HandleGetter implements JavacAnnotationHandler<Getter> {
|
||||
* be a warning if its already there. The default access level is used.
|
||||
*/
|
||||
public void generateGetterForField(Node fieldNode, DiagnosticPosition pos) {
|
||||
AccessLevel level = AccessLevel.PUBLIC;
|
||||
Node errorNode = fieldNode;
|
||||
boolean whineIfExists = false;
|
||||
|
||||
for ( Node child : fieldNode.down() ) {
|
||||
if ( child.getKind() == Kind.ANNOTATION ) {
|
||||
if ( Javac.annotationTypeMatches(Getter.class, child) ) {
|
||||
level = Javac.createAnnotation(Getter.class, child).getInstance().value();
|
||||
errorNode = child;
|
||||
pos = child.get();
|
||||
whineIfExists = true;
|
||||
break;
|
||||
//The annotation will make it happen, so we can skip it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createGetterForField(level, fieldNode, errorNode, pos, whineIfExists);
|
||||
createGetterForField(AccessLevel.PUBLIC, fieldNode, fieldNode, pos, false);
|
||||
}
|
||||
|
||||
@Override public boolean handle(AnnotationValues<Getter> annotation, JCAnnotation ast, Node annotationNode) {
|
||||
|
||||
@@ -66,23 +66,16 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> {
|
||||
* be a warning if its already there. The default access level is used.
|
||||
*/
|
||||
public void generateSetterForField(Node fieldNode, DiagnosticPosition pos) {
|
||||
AccessLevel level = AccessLevel.PUBLIC;
|
||||
Node errorNode = fieldNode;
|
||||
boolean whineIfExists = false;
|
||||
|
||||
for ( Node child : fieldNode.down() ) {
|
||||
if ( child.getKind() == Kind.ANNOTATION ) {
|
||||
if ( Javac.annotationTypeMatches(Setter.class, child) ) {
|
||||
level = Javac.createAnnotation(Setter.class, child).getInstance().value();
|
||||
errorNode = child;
|
||||
pos = child.get();
|
||||
whineIfExists = true;
|
||||
break;
|
||||
//The annotation will make it happen, so we can skip it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createSetterForField(level, fieldNode, errorNode, pos, whineIfExists);
|
||||
createSetterForField(AccessLevel.PUBLIC, fieldNode, fieldNode, pos, false);
|
||||
}
|
||||
|
||||
@Override public boolean handle(AnnotationValues<Setter> annotation, JCAnnotation ast, Node annotationNode) {
|
||||
|
||||
Reference in new issue
Block a user