diff options
Diffstat (limited to 'src/lombok/javac/handlers')
-rw-r--r-- | src/lombok/javac/handlers/HandleGetter.java | 26 | ||||
-rw-r--r-- | src/lombok/javac/handlers/PKG.java | 8 |
2 files changed, 24 insertions, 10 deletions
diff --git a/src/lombok/javac/handlers/HandleGetter.java b/src/lombok/javac/handlers/HandleGetter.java index c993afcd..81915169 100644 --- a/src/lombok/javac/handlers/HandleGetter.java +++ b/src/lombok/javac/handlers/HandleGetter.java @@ -90,16 +90,22 @@ public class HandleGetter implements JavacAnnotationHandler<Getter> { JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get(); String methodName = toGetterName(fieldDecl); - switch ( methodExists(methodName, fieldNode) ) { - case EXISTS_BY_LOMBOK: - return true; - case EXISTS_BY_USER: - if ( whineIfExists ) errorNode.addWarning( - String.format("Not generating %s(): A method with that name already exists", methodName)); - return true; - default: - case NOT_EXISTS: - //continue with creating the getter + for ( String altName : toAllGetterNames(fieldDecl) ) { + switch ( methodExists(altName, fieldNode) ) { + case EXISTS_BY_LOMBOK: + return true; + case EXISTS_BY_USER: + if ( whineIfExists ) { + String altNameExpl = ""; + if ( !altName.equals(methodName) ) altNameExpl = String.format("(%s)", altName); + errorNode.addWarning( + String.format("Not generating %s(): A method with that name already exists%s", methodName, altNameExpl)); + } + return true; + default: + case NOT_EXISTS: + //continue scanning the other alt names. + } } long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC); diff --git a/src/lombok/javac/handlers/PKG.java b/src/lombok/javac/handlers/PKG.java index ef6b3eba..205a2b6e 100644 --- a/src/lombok/javac/handlers/PKG.java +++ b/src/lombok/javac/handlers/PKG.java @@ -45,6 +45,14 @@ class PKG { //Prevent instantiation } + static java.util.List<String> toAllGetterNames(JCVariableDecl field) { + CharSequence fieldName = field.name; + + boolean isBoolean = field.vartype.toString().equals("boolean"); + + return TransformationsUtil.toAllGetterNames(fieldName, isBoolean); + } + /** * @return the likely getter name for the stated field. (e.g. private boolean foo; to isFoo). */ |