diff options
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/CustomLog.java | 2 | ||||
-rwxr-xr-x | src/core/lombok/eclipse/handlers/HandleBuilder.java | 2 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleSuperBuilder.java | 34 | ||||
-rw-r--r-- | src/core/lombok/extern/apachecommons/CommonsLog.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/flogger/Flogger.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/java/Log.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/jbosslog/JBossLog.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/log4j/Log4j.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/log4j/Log4j2.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/slf4j/Slf4j.java | 2 | ||||
-rw-r--r-- | src/core/lombok/extern/slf4j/XSlf4j.java | 2 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSuperBuilder.java | 29 |
12 files changed, 58 insertions, 25 deletions
diff --git a/src/core/lombok/CustomLog.java b/src/core/lombok/CustomLog.java index d1f45f7c..c6ea400d 100644 --- a/src/core/lombok/CustomLog.java +++ b/src/core/lombok/CustomLog.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field based on a custom logger implementation. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index a2dd5057..bb9b6dda 100755 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -983,7 +983,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { } if (field == null) { - FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName, 0, 0); + FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0); fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; fd.modifiers = ClassFileConstants.AccPrivate; fd.type = copyType(bfd.type); diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java index 558c6ec2..e91478e0 100644 --- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java @@ -51,7 +51,6 @@ import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.FieldReference; import org.eclipse.jdt.internal.compiler.ast.IfStatement; import org.eclipse.jdt.internal.compiler.ast.Initializer; -import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NullLiteral; @@ -387,16 +386,16 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { injectMethod(job.builderType, generateStaticFillValuesMethod(job, annInstance.setterPrefix())); } - // Generate abstract self() and build() methods in the abstract builder. - injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName)); - job.setBuilderToAbstract(); - injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName)); - // Create the setter methods in the abstract builder. for (BuilderFieldData bfd : job.builderFields) { generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); } + // Generate abstract self() and build() methods in the abstract builder. + injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName)); + job.setBuilderToAbstract(); + injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName)); + // Create the toString() method for the abstract builder. if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) { List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>(); @@ -948,7 +947,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { } if (field == null) { - FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName, 0, 0); + FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0); fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; fd.modifiers = ClassFileConstants.AccPrivate; fd.type = copyType(bfd.type); @@ -1100,14 +1099,29 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { if (td.fields != null) { for (FieldDeclaration field : td.fields) { if (field instanceof Initializer) continue; - char[][] typeName = field.type.getTypeName(); - if (typeName.length >= 1) // Add the first token, because only that can collide. - usedNames.add(String.valueOf(typeName[0])); + addFirstToken(usedNames, field.type); + } + } + + // 4. Add extends and implements clauses. + addFirstToken(usedNames, td.superclass); + if (td.superInterfaces != null) { + for (TypeReference typeReference : td.superInterfaces) { + addFirstToken(usedNames, typeReference); } } return usedNames; } + + private void addFirstToken(java.util.Set<String> usedNames, TypeReference type) { + if (type == null) + return; + // Add the first token, because only that can collide. + char[][] typeName = type.getTypeName(); + if (typeName != null && typeName.length >= 1) + usedNames.add(String.valueOf(typeName[0])); + } private String generateNonclashingNameFor(String classGenericName, java.util.Set<String> typeParamStrings) { if (!typeParamStrings.contains(classGenericName)) return classGenericName; diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java index ca808329..973f556f 100644 --- a/src/core/lombok/extern/apachecommons/CommonsLog.java +++ b/src/core/lombok/extern/apachecommons/CommonsLog.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/flogger/Flogger.java b/src/core/lombok/extern/flogger/Flogger.java index 3446e949..893032ed 100644 --- a/src/core/lombok/extern/flogger/Flogger.java +++ b/src/core/lombok/extern/flogger/Flogger.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java index f2b5024f..96e52191 100644 --- a/src/core/lombok/extern/java/Log.java +++ b/src/core/lombok/extern/java/Log.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/jbosslog/JBossLog.java b/src/core/lombok/extern/jbosslog/JBossLog.java index 960a111b..a6e5e353 100644 --- a/src/core/lombok/extern/jbosslog/JBossLog.java +++ b/src/core/lombok/extern/jbosslog/JBossLog.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java index 1b4a973b..3db01029 100644 --- a/src/core/lombok/extern/log4j/Log4j.java +++ b/src/core/lombok/extern/log4j/Log4j.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java index 571b0563..3e59a532 100644 --- a/src/core/lombok/extern/log4j/Log4j2.java +++ b/src/core/lombok/extern/log4j/Log4j2.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java index c4aded24..da65e27c 100644 --- a/src/core/lombok/extern/slf4j/Slf4j.java +++ b/src/core/lombok/extern/slf4j/Slf4j.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/slf4j/XSlf4j.java b/src/core/lombok/extern/slf4j/XSlf4j.java index b99554a5..2dfef265 100644 --- a/src/core/lombok/extern/slf4j/XSlf4j.java +++ b/src/core/lombok/extern/slf4j/XSlf4j.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java index 7418ac87..913f838c 100644 --- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java @@ -336,6 +336,11 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { injectMethod(job.builderType, sfvm); } + // Create the setter methods in the abstract builder. + for (BuilderFieldData bfd : job.builderFields) { + generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); + } + // Generate abstract self() and build() methods in the abstract builder. JCMethodDecl asm = generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName); recursiveSetGeneratedBy(asm, annotationNode); @@ -344,11 +349,6 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { recursiveSetGeneratedBy(abm, annotationNode); injectMethod(job.builderType, abm); - // Create the setter methods in the abstract builder. - for (BuilderFieldData bfd : job.builderFields) { - generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); - } - // Create the toString() method for the abstract builder. java.util.List<Included<JavacNode, ToString.Include>> fieldNodes = new ArrayList<Included<JavacNode, ToString.Include>>(); for (BuilderFieldData bfd : job.builderFields) { @@ -1051,9 +1051,28 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { } } + // 4. Add extends and implements clauses. + addFirstToken(usedNames, Javac.getExtendsClause(td)); + for (JCExpression impl : td.getImplementsClause()) { + addFirstToken(usedNames, impl); + } + return usedNames; } + private void addFirstToken(java.util.Set<String> usedNames, JCTree type) { + if (type == null) + return; + if (type instanceof JCTypeApply) { + type = ((JCTypeApply)type).clazz; + } + while (type instanceof JCFieldAccess && ((JCFieldAccess)type).selected != null) { + // Add the first token, because only that can collide. + type = ((JCFieldAccess)type).selected; + } + usedNames.add(type.toString()); + } + private String generateNonclashingNameFor(String classGenericName, java.util.HashSet<String> typeParamStrings) { if (!typeParamStrings.contains(classGenericName)) return classGenericName; int counter = 2; |