diff options
author | daliclass <markhaynes.work@gmail.com> | 2019-05-05 22:28:48 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2019-05-07 15:18:01 +0200 |
commit | d3ae4d994880a1a087108275e101ab4fbb43f071 (patch) | |
tree | f9cbadfbe9df076904e5a3cd0680ddc3ec54d3e4 /src/core/lombok/eclipse/handlers | |
parent | 3496a3e9633cd6526745bcc390877653afad7f09 (diff) | |
download | lombok-d3ae4d994880a1a087108275e101ab4fbb43f071.tar.gz lombok-d3ae4d994880a1a087108275e101ab4fbb43f071.tar.bz2 lombok-d3ae4d994880a1a087108275e101ab4fbb43f071.zip |
[Feature] staticConstructor should use already defined private constructor if available
Diffstat (limited to 'src/core/lombok/eclipse/handlers')
-rwxr-xr-x | src/core/lombok/eclipse/handlers/HandleConstructor.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index 660b9985..c6b51042 100755 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -242,8 +242,7 @@ public class HandleConstructor { ASTNode source = sourceNode.get(); boolean staticConstrRequired = staticName != null && !staticName.equals(""); - - if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return; + if (skipIfConstructorExists != SkipIfConstructorExists.NO) { for (EclipseNode child : typeNode.down()) { if (child.getKind() == Kind.ANNOTATION) { @@ -273,12 +272,18 @@ public class HandleConstructor { if (noArgs && noArgsConstructorExists(typeNode)) return; - ConstructorDeclaration constr = createConstructor( - staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fieldsToParam, forceDefaults, - sourceNode, onConstructor); - injectMethod(typeNode, constr); + if (!(skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS)) { + ConstructorDeclaration constr = createConstructor( + staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fieldsToParam, forceDefaults, + sourceNode, onConstructor); + injectMethod(typeNode, constr); + } + generateStaticConstructor(staticConstrRequired, typeNode, staticName, level, fieldsToParam, source); + } + + private void generateStaticConstructor(boolean staticConstrRequired, EclipseNode typeNode, String staticName, AccessLevel level, Collection<EclipseNode> fields, ASTNode source) { if (staticConstrRequired) { - MethodDeclaration staticConstr = createStaticConstructor(level, staticName, typeNode, fieldsToParam, source); + MethodDeclaration staticConstr = createStaticConstructor(level, staticName, typeNode, fields, source); injectMethod(typeNode, staticConstr); } } |