From f38811779b9280bff7adebde64ed23b554a42dd9 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 20 Jul 2015 22:39:35 +0200 Subject: added javac impl of toBuilder along with test file. --- src/core/lombok/eclipse/handlers/HandleBuilder.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/core/lombok/eclipse') diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index c7ff714b..ee6dfd70 100644 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -223,6 +223,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { char[][] pkg = null; if (md.returnType.dimensions() > 0) { annotationNode.addError(TO_BUILDER_NOT_SUPPORTED); + return; } if (md.returnType instanceof SingleTypeReference) { @@ -243,9 +244,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { return; } - EclipseNode selfType = parent; - while (selfType != null && selfType.getKind() != Kind.TYPE) selfType = selfType.up(); - if (selfType == null || !equals(selfType.getName(), token)) { + if (tdParent == null || !equals(tdParent.getName(), token)) { annotationNode.addError(TO_BUILDER_NOT_SUPPORTED); return; } @@ -274,12 +273,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { if (!Arrays.equals(((SingleTypeReference) tpOnRet[i]).token, onMethod.name)) continue; pos = i; } - if (pos == -1) { - annotationNode.addError("@Builder(toBuilder=true) requires that each type parameter on the static method is part of the typeargs of the return value. Type parameter " + new String(onMethod.name) + " is not part of the return type."); - return; - } - - if (tpOnType == null || tpOnType.length <= pos) { + if (pos == -1 || tpOnType == null || tpOnType.length <= pos) { annotationNode.addError("@Builder(toBuilder=true) requires that each type parameter on the static method is part of the typeargs of the return value. Type parameter " + new String(onMethod.name) + " is not part of the return type."); return; } @@ -388,8 +382,8 @@ public class HandleBuilder extends EclipseAnnotationHandler { if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) { ConstructorDeclaration cd = HandleConstructor.createConstructor( - AccessLevel.PACKAGE, builderType, Collections.emptyList(), null, - annotationNode, Collections.emptyList()); + AccessLevel.PACKAGE, builderType, Collections.emptyList(), null, + annotationNode, Collections.emptyList()); if (cd != null) injectMethod(builderType, cd); } -- cgit