diff options
-rw-r--r-- | doc/changelog.markdown | 1 | ||||
-rw-r--r-- | src/core/lombok/core/ImportList.java | 8 | ||||
-rw-r--r-- | src/core/lombok/core/TypeResolver.java | 4 | ||||
-rw-r--r-- | src/core/lombok/eclipse/EclipseImportList.java | 9 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacImportList.java | 9 |
5 files changed, 24 insertions, 7 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 90cad054..1a549866 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -8,6 +8,7 @@ Lombok Changelog * FEATURE: You can now configure a builder's 'setter' prefixes via `@Builder(setterPrefix = "set")` for example. We discourage doing this, but if some library you use requires them, have at it. [Pull Request #2174](https://github.com/rzwitserloot/lombok/pull/2174], [Issue #1805](https://github.com/rzwitserloot/lombok/issues/1805). * FEATURE: If you use `@Builder`'s `@Singular`, a plural form is also generated, which has the effect of adding all elements in the passed collection. If you pass a null reference, this would result in a message-less `NullPointerException`. Now, it results in that exception but with a useful message attached, and you can choose other behaviors as well via a parameter on the `@Singular` annotation and via `lombok.config`; you can even choose treat them as empty collections; this can be useful when deserializing (e.g. Jackson JSON) and JPA/Hibernate code. [Issue #2221](https://github.com/rzwitserloot/lombok/issues/2221]. [singular documentation](https://projectlombok.org/features/Builder). * FEATURE: Tired of being unable to use `@javax.annotation.ParametersAreNonnullByDefault` or `@org.eclipse.jdt.annotation.NonNullByDefault` because then the equals method that lombok generates isn't valid? Fret no more; lombok can now add nullity annotations where relevant. Set the flavour of nullity annotation you prefer in your `lombok.config`. Applies to the return value of `toString` and `withX` methods, and the parameter of `equals`, `canEqual`, and the plural form of `@Singular` marked fields for builder classes. [Issue #788](https://github.com/rzwitserloot/lombok/issues/788) +* BUGFIX: `lombok.experimental.Wither` has been deprecated (it has been renamed to `lombok.With`). However, the intent is that lombok still handles the old annotation in case you haven't updated your lombok dep yet. However, only a star import on `lombok.experimental.*` worked; an explicit one would cause lombok to not generate any with method. [Issue #2235](https://github.com/rzwitserloot/lombok/issues/2235) * BUGFIX: Referring to an inner class inside the generics on a class marked with `@SuperBuilder` would cause the error `wrong number of type arguments; required 3` [Issue #2262](https://github.com/rzwitserloot/lombok/issues/2262); fixed by github user [`@Lekanich`](https://github.com/rzwitserloot/lombok/issues/2262) - thank you! * BUGFIX: Some of the code generated by `@Builder` did not include `this.` prefixes when accessing fields. While semantically it didn't matter, if you use the 'add this prefix for field accesses' save action in eclipse, the save action would break. [Issue #2327](https://github.com/rzwitserloot/lombok/issues/2327) * BUGFIX: When lombok copies javadoc from fields to relevant methods, it should generate an appropriate `@return this` line if lombok copies the javadoc to a generated setter that is chainable (returns itself). It didn't do that when generating the 'setters' in a `@Builder`. Lombok also didn't generate an appropriate `@return` item for `@With` methods. The javadoc has also been updated slightly (the `this` reference in the javadoc is now rendered in a code tag).[Issue #2323](https://github.com/rzwitserloot/lombok/issues/2323) diff --git a/src/core/lombok/core/ImportList.java b/src/core/lombok/core/ImportList.java index 95e266c4..208645a0 100644 --- a/src/core/lombok/core/ImportList.java +++ b/src/core/lombok/core/ImportList.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Project Lombok Authors. + * Copyright (C) 2013-2020 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 @@ -30,6 +30,12 @@ public interface ImportList { String getFullyQualifiedNameForSimpleName(String unqualified); /** + * If there is an explicit import of the stated unqualified type name, return that. Otherwise, return null. + * Do not translate the produced fully qualified name to the alias. + */ + String getFullyQualifiedNameForSimpleNameNoAliasing(String unqualified); + + /** * Returns true if the package name is explicitly star-imported, OR the packageName refers to this source file's own package name, OR packageName is 'java.lang'. */ boolean hasStarImport(String packageName); diff --git a/src/core/lombok/core/TypeResolver.java b/src/core/lombok/core/TypeResolver.java index 2c36d1fc..4f2df72e 100644 --- a/src/core/lombok/core/TypeResolver.java +++ b/src/core/lombok/core/TypeResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2019 The Project Lombok Authors. + * Copyright (C) 2009-2020 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 @@ -57,7 +57,7 @@ public class TypeResolver { int firstDot = typeRef.indexOf('.'); if (firstDot == -1) firstDot = typeRef.length(); String firstTypeRef = typeRef.substring(0, firstDot); - String fromExplicitImport = imports.getFullyQualifiedNameForSimpleName(firstTypeRef); + String fromExplicitImport = imports.getFullyQualifiedNameForSimpleNameNoAliasing(firstTypeRef); if (fromExplicitImport != null) { String fqn = fromExplicitImport + typeRef.substring(firstDot); if (qualifieds.contains(fqn)) return LombokInternalAliasing.processAliases(fqn); diff --git a/src/core/lombok/eclipse/EclipseImportList.java b/src/core/lombok/eclipse/EclipseImportList.java index 6d60f5aa..9a04403d 100644 --- a/src/core/lombok/eclipse/EclipseImportList.java +++ b/src/core/lombok/eclipse/EclipseImportList.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Project Lombok Authors. + * Copyright (C) 2013-2020 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 @@ -45,6 +45,11 @@ public class EclipseImportList implements ImportList { } @Override public String getFullyQualifiedNameForSimpleName(String unqualified) { + String q = getFullyQualifiedNameForSimpleNameNoAliasing(unqualified); + return q == null ? null : LombokInternalAliasing.processAliases(q); + } + + @Override public String getFullyQualifiedNameForSimpleNameNoAliasing(String unqualified) { if (imports != null) { outer: for (ImportReference imp : imports) { @@ -54,7 +59,7 @@ public class EclipseImportList implements ImportList { int len = token.length; if (len != unqualified.length()) continue; for (int i = 0; i < len; i++) if (token[i] != unqualified.charAt(i)) continue outer; - return LombokInternalAliasing.processAliases(toQualifiedName(tokens)); + return toQualifiedName(tokens); } } return null; diff --git a/src/core/lombok/javac/JavacImportList.java b/src/core/lombok/javac/JavacImportList.java index 8de61afc..d498c2ab 100644 --- a/src/core/lombok/javac/JavacImportList.java +++ b/src/core/lombok/javac/JavacImportList.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 The Project Lombok Authors. + * Copyright (C) 2013-2020 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 @@ -43,13 +43,18 @@ public class JavacImportList implements ImportList { } @Override public String getFullyQualifiedNameForSimpleName(String unqualified) { + String q = getFullyQualifiedNameForSimpleNameNoAliasing(unqualified); + return q == null ? null : LombokInternalAliasing.processAliases(q); + } + + @Override public String getFullyQualifiedNameForSimpleNameNoAliasing(String unqualified) { for (JCTree def : defs) { if (!(def instanceof JCImport)) continue; JCTree qual = ((JCImport) def).qualid; if (!(qual instanceof JCFieldAccess)) continue; String simpleName = ((JCFieldAccess) qual).name.toString(); if (simpleName.equals(unqualified)) { - return LombokInternalAliasing.processAliases(qual.toString()); + return qual.toString(); } } |