aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-06-18 04:23:15 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-06-18 04:23:15 +0200
commite1c39bbc601408decb0ae147d181708a5af41307 (patch)
treef3a620da1778ae4b9654433bec65841a95ff5067 /src/core/lombok/eclipse/handlers
parenteb3d32c718d9ef46fd30bc677147cda85318fb9c (diff)
downloadlombok-e1c39bbc601408decb0ae147d181708a5af41307.tar.gz
lombok-e1c39bbc601408decb0ae147d181708a5af41307.tar.bz2
lombok-e1c39bbc601408decb0ae147d181708a5af41307.zip
javac builder implementation. Passes all tests.
Added toString() impl for builders in both eclipse and javac. Added all documentation, though it'll need some reviewing.
Diffstat (limited to 'src/core/lombok/eclipse/handlers')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleToString.java8
2 files changed, 10 insertions, 5 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index d15f00e6..e2bf5fe2 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -78,7 +78,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
if (buildMethodName == null) builderMethodName = "build";
if (builderClassName == null) builderClassName = "";
- if (checkName("builderMethodName", builderMethodName, annotationNode)) return;
+ if (!checkName("builderMethodName", builderMethodName, annotationNode)) return;
if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
if (!builderClassName.isEmpty()) {
if (!checkName("builderClassName", builderClassName, annotationNode)) return;
@@ -200,6 +200,11 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
if (md != null) injectMethod(builderType, md);
}
+ if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) {
+ MethodDeclaration md = HandleToString.createToString(builderType, fieldNodes, true, false, ast, FieldAccess.ALWAYS_FIELD);
+ if (md != null) injectMethod(builderType, md);
+ }
+
if (methodExists(builderMethodName, tdParent, -1) == MemberExistsResult.NOT_EXISTS) {
MethodDeclaration md = generateBuilderMethod(builderMethodName, builderClassName, tdParent, typeParams, ast);
if (md != null) injectMethod(tdParent, md);
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java
index d864153f..1193af31 100644
--- a/src/core/lombok/eclipse/handlers/HandleToString.java
+++ b/src/core/lombok/eclipse/handlers/HandleToString.java
@@ -170,7 +170,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
}
}
- private MethodDeclaration createToString(EclipseNode type, Collection<EclipseNode> fields,
+ static MethodDeclaration createToString(EclipseNode type, Collection<EclipseNode> fields,
boolean includeFieldNames, boolean callSuper, ASTNode source, FieldAccess fieldAccess) {
String typeName = getTypeName(type);
char[] suffix = ")".toCharArray();
@@ -282,7 +282,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
return method;
}
- private String getTypeName(EclipseNode type) {
+ private static String getTypeName(EclipseNode type) {
String typeName = getSingleTypeName(type);
EclipseNode upType = type.up();
while (upType.getKind() == Kind.TYPE) {
@@ -292,7 +292,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
return typeName;
}
- private String getSingleTypeName(EclipseNode type) {
+ private static String getSingleTypeName(EclipseNode type) {
TypeDeclaration typeDeclaration = (TypeDeclaration)type.get();
char[] rawTypeName = typeDeclaration.name;
return rawTypeName == null ? "" : new String(rawTypeName);
@@ -301,7 +301,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
private static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
"byte", "short", "int", "long", "char", "boolean", "double", "float")));
- private NameReference generateQualifiedNameRef(ASTNode source, char[]... varNames) {
+ private static NameReference generateQualifiedNameRef(ASTNode source, char[]... varNames) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
NameReference ref;