aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-01-29 01:33:40 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-01-29 01:34:22 +0100
commit3d0beec38d8d19e8c90df56d7f4297d1c5f332ee (patch)
tree74f92437acdc3ccfd6a3b5c6f57f596d9216821f /src/core/lombok/eclipse
parent960811364b792654cd154787758fbb16f2600f09 (diff)
downloadlombok-3d0beec38d8d19e8c90df56d7f4297d1c5f332ee.tar.gz
lombok-3d0beec38d8d19e8c90df56d7f4297d1c5f332ee.tar.bz2
lombok-3d0beec38d8d19e8c90df56d7f4297d1c5f332ee.zip
[fixes #2011] If you have a field named `build` or `toString`, and you generate a builder, that builder wouldn’t make the build or toString methods because it thinks the builder-setter methods it just generated that so happen to have that name indicate you don’t want lombok to do that.
You really shouldn’t name any fields builder or toString, though.
Diffstat (limited to 'src/core/lombok/eclipse')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 890a04bc..3391b99d 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2018 The Project Lombok Authors.
+ * Copyright (C) 2013-2019 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -87,6 +87,7 @@ import lombok.core.HandlerPriority;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.HandleConstructor.SkipIfConstructorExists;
@@ -460,9 +461,13 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
makeSetterMethodsForBuilder(builderType, bfd, annotationNode, fluent, chain);
}
- if (methodExists(buildMethodName, builderType, -1) == MemberExistsResult.NOT_EXISTS) {
- MethodDeclaration md = generateBuildMethod(tdParent, isStatic, buildMethodName, nameOfStaticBuilderMethod, returnType, builderFields, builderType, thrownExceptions, addCleaning, ast);
- if (md != null) injectMethod(builderType, md);
+ {
+ MemberExistsResult methodExists = methodExists(buildMethodName, builderType, -1);
+ if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0);
+ if (methodExists == MemberExistsResult.NOT_EXISTS) {
+ MethodDeclaration md = generateBuildMethod(tdParent, isStatic, buildMethodName, nameOfStaticBuilderMethod, returnType, builderFields, builderType, thrownExceptions, addCleaning, ast);
+ if (md != null) injectMethod(builderType, md);
+ }
}
if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) {