Skip to content

Commit

Permalink
[builderParentClass] Code to handle builder on enums removed; that do…
Browse files Browse the repository at this point in the history
…esn’t make a heck of a lot of sense and enums aren’t extensible in the first place. Also fixed up a wrong access level; now all existing builder tests pass.
  • Loading branch information
rzwitserloot committed Mar 27, 2018
1 parent cde47ab commit 2a6c0c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/core/lombok/eclipse/handlers/HandleBuilder.java
Expand Up @@ -604,12 +604,9 @@ private void generateBuilderBasedConstructor(EclipseNode typeNode, List<BuilderF
TypeDeclaration typeDeclaration = ((TypeDeclaration) typeNode.get());
long p = (long) source.sourceStart << 32 | source.sourceEnd;

boolean isEnum = (((TypeDeclaration) typeNode.get()).modifiers & ClassFileConstants.AccEnum) != 0;
AccessLevel level = isEnum ? AccessLevel.PRIVATE : AccessLevel.PROTECTED;

ConstructorDeclaration constructor = new ConstructorDeclaration(((CompilationUnitDeclaration) typeNode.top().get()).compilationResult);

constructor.modifiers = toEclipseModifier(level);
constructor.modifiers = toEclipseModifier(AccessLevel.PROTECTED);
constructor.selector = typeDeclaration.name;
if (callBuilderBasedSuperConstructor) {
constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.Super);
Expand Down
7 changes: 2 additions & 5 deletions src/core/lombok/javac/handlers/HandleBuilder.java
Expand Up @@ -195,7 +195,7 @@ private static class BuilderFieldData {
boolean callBuilderBasedSuperConstructor = extendsClause != null;
generateBuilderBasedConstructor(tdParent, builderFields, annotationNode, builderClassName, callBuilderBasedSuperConstructor);
} else {
handleConstructor.generateConstructor(tdParent, AccessLevel.PROTECTED, List.<JCAnnotation>nil(), allFields.toList(), false, null, SkipIfConstructorExists.I_AM_BUILDER, annotationNode);
handleConstructor.generateConstructor(tdParent, AccessLevel.PACKAGE, List.<JCAnnotation>nil(), allFields.toList(), false, null, SkipIfConstructorExists.I_AM_BUILDER, annotationNode);
}

returnType = namePlusTypeParamsToTypeReference(tdParent.getTreeMaker(), td.name, td.typarams);
Expand Down Expand Up @@ -569,9 +569,6 @@ private JCMethodDecl generateToBuilderMethod(String toBuilderMethodName, String
private void generateBuilderBasedConstructor(JavacNode typeNode, java.util.List<BuilderFieldData> builderFields, JavacNode source, String builderClassnameAsParameter, boolean callBuilderBasedSuperConstructor) {
JavacTreeMaker maker = typeNode.getTreeMaker();

boolean isEnum = (((JCClassDecl) typeNode.get()).mods.flags & Flags.ENUM) != 0;
AccessLevel level = isEnum ? AccessLevel.PRIVATE : AccessLevel.PROTECTED;

ListBuffer<JCStatement> nullChecks = new ListBuffer<JCStatement>();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();

Expand Down Expand Up @@ -599,7 +596,7 @@ private void generateBuilderBasedConstructor(JavacNode typeNode, java.util.List<
statements.append(maker.Exec(assign));
}

JCModifiers mods = maker.Modifiers(toJavacModifier(level), List.<JCAnnotation>nil());
JCModifiers mods = maker.Modifiers(toJavacModifier(AccessLevel.PROTECTED), List.<JCAnnotation>nil());

// Create a constructor that has just the builder as parameter.
ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
Expand Down

0 comments on commit 2a6c0c1

Please sign in to comment.