diff options
-rw-r--r-- | src/core/lombok/core/TransformationsUtil.java | 11 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 2 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 23 |
3 files changed, 17 insertions, 19 deletions
diff --git a/src/core/lombok/core/TransformationsUtil.java b/src/core/lombok/core/TransformationsUtil.java index d0eea4a2..60d9bab0 100644 --- a/src/core/lombok/core/TransformationsUtil.java +++ b/src/core/lombok/core/TransformationsUtil.java @@ -150,14 +150,15 @@ public class TransformationsUtil { fieldName = removePrefix(fieldName, ac.prefix()); if (fieldName == null) return null; - if (ac.fluent()) return fieldName.toString(); + String fName = fieldName.toString(); + if (ac.fluent()) return fName; - if (isBoolean && fieldName.toString().startsWith("is") && fieldName.length() > 2 && !Character.isLowerCase(fieldName.charAt(2))) { + if (isBoolean && fName.startsWith("is") && fieldName.length() > 2 && !Character.isLowerCase(fName.charAt(2))) { // The field is for example named 'isRunning'. - return "set" + fieldName.toString().substring(2); + return "set" + fName.substring(2); } - return buildName("set", fieldName.toString()); + return buildName("set", fName); } /** @@ -215,7 +216,7 @@ public class TransformationsUtil { if (acc.fluent()) { names.add(baseName); } else { - names.add("set" + baseName); + names.add(buildName("set", baseName)); } } diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index d0fc0f33..3c2ab904 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -990,7 +990,7 @@ public class EclipseHandlerUtil { return createAnnotation(Accessors.class, node); } } - current = field.up(); + current = current.up(); } return AnnotationValues.of(Accessors.class, field); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 245636b7..c8538296 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -279,9 +279,7 @@ public class JavacHandlerUtil { */ public static java.util.List<String> toAllGetterNames(JavacNode field) { String fieldName = field.getName(); - - boolean isBoolean = ((JCVariableDecl) field.get()).vartype.toString().equals("boolean"); - + boolean isBoolean = isBoolean(field); AnnotationValues<Accessors> accessors = JavacHandlerUtil.getAccessorsForField(field); return TransformationsUtil.toAllGetterNames(accessors, fieldName, isBoolean); @@ -294,9 +292,7 @@ public class JavacHandlerUtil { */ public static String toGetterName(JavacNode field) { String fieldName = field.getName(); - - boolean isBoolean = ((JCVariableDecl) field.get()).vartype.toString().equals("boolean"); - + boolean isBoolean = isBoolean(field); AnnotationValues<Accessors> accessors = JavacHandlerUtil.getAccessorsForField(field); return TransformationsUtil.toGetterName(accessors, fieldName, isBoolean); @@ -308,9 +304,7 @@ public class JavacHandlerUtil { */ public static java.util.List<String> toAllSetterNames(JavacNode field) { String fieldName = field.getName(); - - boolean isBoolean = ((JCVariableDecl) field.get()).vartype.toString().equals("boolean"); - + boolean isBoolean = isBoolean(field); AnnotationValues<Accessors> accessors = JavacHandlerUtil.getAccessorsForField(field); return TransformationsUtil.toAllSetterNames(accessors, fieldName, isBoolean); @@ -323,14 +317,17 @@ public class JavacHandlerUtil { */ public static String toSetterName(JavacNode field) { String fieldName = field.getName(); - - boolean isBoolean = ((JCVariableDecl) field.get()).toString().equals("boolean"); - + boolean isBoolean = isBoolean(field); AnnotationValues<Accessors> accessors = JavacHandlerUtil.getAccessorsForField(field); return TransformationsUtil.toSetterName(accessors, fieldName, isBoolean); } + private static boolean isBoolean(JavacNode field) { + JCExpression varType = ((JCVariableDecl) field.get()).vartype; + return varType != null && varType.toString().equals("boolean"); + } + public static AnnotationValues<Accessors> getAccessorsForField(JavacNode field) { for (JavacNode node : field.down()) { if (annotationTypeMatches(Accessors.class, node)) { @@ -345,7 +342,7 @@ public class JavacHandlerUtil { return createAnnotation(Accessors.class, node); } } - current = field.up(); + current = current.up(); } return AnnotationValues.of(Accessors.class, field); |