diff options
author | Bulgakov Alexander <buls@yandex.ru> | 2019-05-20 13:10:14 +0300 |
---|---|---|
committer | Bulgakov Alexander <buls@yandex.ru> | 2019-05-20 13:10:14 +0300 |
commit | 71aea086e4fa9d3fa77e29c5a208ef8e7458c387 (patch) | |
tree | c6b4aac622fa9e88210bbc0b813f8d3cbd7079b5 /src/core/lombok | |
parent | 1fec035aa546b7a033acb67cf4f7c1afb8a79f52 (diff) | |
parent | c479920db17e36392fa69e386156c982fe60cc27 (diff) | |
download | lombok-71aea086e4fa9d3fa77e29c5a208ef8e7458c387.tar.gz lombok-71aea086e4fa9d3fa77e29c5a208ef8e7458c387.tar.bz2 lombok-71aea086e4fa9d3fa77e29c5a208ef8e7458c387.zip |
Merge branch 'master' into feature/typeInferenceImprovements
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/core/Version.java | 6 | ||||
-rwxr-xr-x | src/core/lombok/eclipse/handlers/HandleConstructor.java | 19 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleConstructor.java | 18 |
3 files changed, 28 insertions, 15 deletions
diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index e3d7368e..0a4f7e3d 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -30,9 +30,9 @@ public class Version { // ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries). // Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example. // Official builds always end in an even number. (Since 0.10.2). - private static final String VERSION = "1.18.8"; -// private static final String RELEASE_NAME = "Edgy Guinea Pig"; - private static final String RELEASE_NAME = "Envious Ferret"; + private static final String VERSION = "1.18.9"; + private static final String RELEASE_NAME = "Edgy Guinea Pig"; +// private static final String RELEASE_NAME = "Envious Ferret"; // Named version history: // Angry Butterfly 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); } } diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index 3c434d40..e0456782 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -55,8 +55,10 @@ import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; +import lombok.core.LombokNode; import lombok.delombok.LombokOptionsFactory; import lombok.javac.Javac; +import lombok.javac.JavacAST; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; @@ -219,8 +221,8 @@ public class HandleConstructor { private void generate(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, boolean allToDefault, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source, boolean noArgs) { boolean staticConstrRequired = staticName != null && !staticName.equals(""); - if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return; if (skipIfConstructorExists != SkipIfConstructorExists.NO) { + for (JavacNode child : typeNode.down()) { if (child.getKind() == Kind.ANNOTATION) { boolean skipGeneration = annotationTypeMatches(NoArgsConstructor.class, child) || @@ -230,7 +232,6 @@ public class HandleConstructor { if (!skipGeneration && skipIfConstructorExists == SkipIfConstructorExists.YES) { skipGeneration = annotationTypeMatches(Builder.class, child); } - if (skipGeneration) { if (staticConstrRequired) { // @Data has asked us to generate a constructor, but we're going to skip this instruction, as an explicit 'make a constructor' annotation @@ -246,8 +247,7 @@ public class HandleConstructor { } if (noArgs && noArgsConstructorExists(typeNode)) return; - - JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, onConstructor, typeNode, fields, allToDefault, source); + ListBuffer<Type> argTypes = new ListBuffer<Type>(); for (JavacNode fieldNode : fields) { Type mirror = getMirrorForFieldType(fieldNode); @@ -258,7 +258,15 @@ public class HandleConstructor { argTypes.append(mirror); } List<Type> argTypes_ = argTypes == null ? null : argTypes.toList(); - injectMethod(typeNode, constr, argTypes_, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID)); + + if (!(skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS)) { + JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, onConstructor, typeNode, fields, allToDefault, source); + injectMethod(typeNode, constr, argTypes_, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID)); + } + generateStaticConstructor(staticConstrRequired, typeNode, staticName, level, allToDefault, fields, source, argTypes_); + } + + private void generateStaticConstructor(boolean staticConstrRequired, JavacNode typeNode, String staticName, AccessLevel level, boolean allToDefault, List<JavacNode> fields, LombokNode<JavacAST, JavacNode, JCTree> source, List<Type> argTypes_) { if (staticConstrRequired) { ClassSymbol sym = ((JCClassDecl) typeNode.get()).sym; Type returnType = sym == null ? null : sym.type; |