aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/Builder.java4
-rw-r--r--src/core/lombok/ConfigurationKeys.java9
-rw-r--r--src/core/lombok/EqualsAndHashCode.java11
-rw-r--r--src/core/lombok/Singular.java2
-rw-r--r--src/core/lombok/With.java2
-rw-r--r--src/core/lombok/core/AnnotationProcessor.java7
-rw-r--r--src/core/lombok/core/AnnotationValues.java8
-rw-r--r--src/core/lombok/core/LombokNode.java14
-rw-r--r--src/core/lombok/core/PostCompiler.java10
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java30
-rw-r--r--src/core/lombok/core/handlers/InclusionExclusionUtils.java62
-rw-r--r--src/core/lombok/eclipse/EclipseAST.java3
-rw-r--r--src/core/lombok/eclipse/EclipseNode.java42
-rw-r--r--src/core/lombok/eclipse/TransformEclipseAST.java36
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java144
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java29
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleConstructor.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java12
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java9
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java36
-rw-r--r--src/core/lombok/eclipse/handlers/HandleNonNull.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java73
-rw-r--r--src/core/lombok/eclipse/handlers/HandleUtilityClass.java2
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java12
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java12
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java8
-rw-r--r--src/core/lombok/experimental/WithBy.java2
-rw-r--r--src/core/lombok/javac/JavacAST.java11
-rw-r--r--src/core/lombok/javac/JavacNode.java33
-rw-r--r--src/core/lombok/javac/JavacResolution.java66
-rw-r--r--src/core/lombok/javac/JavacTransformer.java29
-rw-r--r--src/core/lombok/javac/apt/Javac9BaseFileObjectWrapper.java111
-rw-r--r--src/core/lombok/javac/apt/LombokFileObjects.java154
-rw-r--r--src/core/lombok/javac/apt/LombokProcessor.java26
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java26
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleDelegate.java22
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java20
-rw-r--r--src/core/lombok/javac/handlers/HandleJacksonized.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java33
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java41
-rw-r--r--src/core/lombok/javac/handlers/HandleUtilityClass.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleWith.java3
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java125
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java16
45 files changed, 821 insertions, 503 deletions
diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java
index 4ca3da65..64294e4b 100644
--- a/src/core/lombok/Builder.java
+++ b/src/core/lombok/Builder.java
@@ -32,8 +32,8 @@ import java.lang.annotation.Target;
* that contains a member which is annotated with {@code @Builder}.
* <p>
* If a member is annotated, it must be either a constructor or a method. If a class is annotated,
- * then a private constructor is generated with all fields as arguments
- * (as if {@code @AllArgsConstructor(access = AccessLevel.PRIVATE)} is present
+ * then a package-private constructor is generated with all fields as arguments
+ * (as if {@code @AllArgsConstructor(access = AccessLevel.PACKAGE)} is present
* on the class), and it is as if this constructor has been annotated with {@code @Builder} instead.
* Note that this constructor is only generated if you haven't written any constructors and also haven't
* added any explicit {@code @XArgsConstructor} annotations. In those cases, lombok will assume an all-args
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java
index 46cf7412..01a4b576 100644
--- a/src/core/lombok/ConfigurationKeys.java
+++ b/src/core/lombok/ConfigurationKeys.java
@@ -90,6 +90,13 @@ public class ConfigurationKeys {
public static final ConfigurationKey<Boolean> ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS = new ConfigurationKey<Boolean>("lombok.extern.findbugs.addSuppressFBWarnings", "Generate @edu.umd.cs.findbugs.annotations.SuppressFBWarnings on all generated code (default: false).") {};
/**
+ * lombok configuration: {@code lombok.addSuppressWarnings} = {@code true} | {@code false}.
+ *
+ * If {@code true}, lombok generates {@code @java.lang.SuppressWarnings("all")} on all fields, methods, and types that are generated.
+ */
+ public static final ConfigurationKey<Boolean> ADD_SUPPRESSWARNINGS_ANNOTATIONS = new ConfigurationKey<Boolean>("lombok.addSuppressWarnings", "Generate @java.lang.SuppressWarnings(\"all\") on all generated code (default: true).") {};
+
+ /**
* lombok configuration: {@code lombok.addNullAnnotations = }one of: [{@code none}, {@code javax}, {@code eclipse}, {@code jetbrains}, {@code netbeans}, {@code androidx}, {@code android.support}, {@code checkerframework}, {@code findbugs}, {@code spring}, {@code JML}, or a custom set of fully qualified annotation types].
*
* Lombok generally copies relevant nullity annotations from your source code to the right places. However, sometimes lombok generates code where the nullability of some node is not dependent on something in your source code. You can configure lombok to add an appropriate nullity annotation in this case.<ul>
@@ -133,7 +140,7 @@ public class ConfigurationKeys {
* NB: GWT projects, and probably android projects, should explicitly set this key to {@code true} for the entire project.
*
* <br>
- * <em>BREAKING CHANGE</em>: Starting with lombok v1.16.20, defaults to {@code false} instead of {@code true}, as {@code @ConstructorProperties} requires extra modules in JDK9.
+ * <em>BREAKING CHANGE</em>: Starting with lombok v1.16.20, defaults to {@code true} instead of {@code false}, as {@code @ConstructorProperties} requires extra modules in JDK9.
*
* @see ConfigurationKeys#ANY_CONSTRUCTOR_ADD_CONSTRUCTOR_PROPERTIES
* @deprecated Since version 2.0, use {@link #ANY_CONSTRUCTOR_ADD_CONSTRUCTOR_PROPERTIES} instead.
diff --git a/src/core/lombok/EqualsAndHashCode.java b/src/core/lombok/EqualsAndHashCode.java
index e752165c..6805d214 100644
--- a/src/core/lombok/EqualsAndHashCode.java
+++ b/src/core/lombok/EqualsAndHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 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
@@ -122,5 +122,14 @@ public @interface EqualsAndHashCode {
* @return If present, this method serves as replacement for the named field.
*/
String replaces() default "";
+
+ /**
+ * Higher ranks are considered first. Members of the same rank are considered in the order they appear in the source file.
+ *
+ * If not explicitly set, the {@code default} rank for primitives is 1000, and for primitive wrappers 800.
+ *
+ * @return ordering within the generating {@code equals} and {@code hashCode} methods; higher numbers are considered first.
+ */
+ int rank() default 0;
}
}
diff --git a/src/core/lombok/Singular.java b/src/core/lombok/Singular.java
index 2ceaad58..08b53973 100644
--- a/src/core/lombok/Singular.java
+++ b/src/core/lombok/Singular.java
@@ -36,6 +36,6 @@ public @interface Singular {
/** @return The singular name of this field. If it's a normal english plural, lombok will figure it out automatically. Otherwise, this parameter is mandatory. */
String value() default "";
- /** @return If true, the plural variant (which takes a collection and adds each element inside) will treat {@code null} as an empty collection, i.e. do nothing. If {@code false) (the default), it is null checked as if annotated with {@code @lombok.NonNull}. */
+ /** @return If true, the plural variant (which takes a collection and adds each element inside) will treat {@code null} as an empty collection, i.e. do nothing. If {@code false} (the default), it is null checked as if annotated with {@code @lombok.NonNull}. */
boolean ignoreNullCollections() default false;
}
diff --git a/src/core/lombok/With.java b/src/core/lombok/With.java
index 141d1fa6..417d8b31 100644
--- a/src/core/lombok/With.java
+++ b/src/core/lombok/With.java
@@ -26,8 +26,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import lombok.AccessLevel;
-
/**
* Put on any field to make lombok build a 'with' - a withX method which produces a clone of this object (except for 1 field which gets a new value).
* <p>
diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java
index ce93a069..d4a92408 100644
--- a/src/core/lombok/core/AnnotationProcessor.java
+++ b/src/core/lombok/core/AnnotationProcessor.java
@@ -83,7 +83,12 @@ public class AnnotationProcessor extends AbstractProcessor {
for (Class<?> procEnvClass = procEnv.getClass(); procEnvClass != null; procEnvClass = procEnvClass.getSuperclass()) {
try {
- Field field = Permit.getField(procEnvClass, "delegate");
+ Field field;
+ try {
+ field = Permit.getField(procEnvClass, "delegate");
+ } catch (NoSuchFieldException e) {
+ field = Permit.getField(procEnvClass, "processingEnv");
+ }
Object delegate = field.get(procEnv);
return tryRecursivelyObtainJavacProcessingEnvironment((ProcessingEnvironment) delegate);
diff --git a/src/core/lombok/core/AnnotationValues.java b/src/core/lombok/core/AnnotationValues.java
index eec5abd8..78bb1fb5 100644
--- a/src/core/lombok/core/AnnotationValues.java
+++ b/src/core/lombok/core/AnnotationValues.java
@@ -411,6 +411,14 @@ public class AnnotationValues<A extends Annotation> {
List<Object> l = getActualExpressions(annotationMethodName);
return l.isEmpty() ? null : l.get(0);
}
+
+ /**
+ * Returns the guessed value for the provided {@code annotationMethodName}.
+ */
+ public Object getValueGuess(String annotationMethodName) {
+ AnnotationValue v = values.get(annotationMethodName);
+ return v == null || v.valueGuesses.isEmpty() ? null : v.valueGuesses.get(0);
+ }
/** Generates an error message on the stated annotation value (you should only call this method if you know it's there!) */
public void setError(String annotationMethodName, String message) {
diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java
index e52cd5b3..abfc66a6 100644
--- a/src/core/lombok/core/LombokNode.java
+++ b/src/core/lombok/core/LombokNode.java
@@ -288,9 +288,23 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A,
public abstract boolean isStatic();
public abstract boolean isFinal();
public abstract boolean isTransient();
+ public abstract boolean isPrimitive();
public abstract boolean isEnumMember();
public abstract boolean isEnumType();
+ /**
+ * The 'type' of the field or method, or {@code null} if this node is neither.
+ *
+ * The type is as it is written in the code (no resolution), includes array dimensions,
+ * but not necessarily generics.
+ *
+ * The main purpose of this method is to verify this type against a list of known types,
+ * like primitives or primitive wrappers.
+ *
+ * @return The 'type' of the field or method, or {@code null} if this node is neither.
+ */
+ public abstract String fieldOrMethodBaseType();
+
public abstract int countMethodParameters();
public abstract int getStartPos();
diff --git a/src/core/lombok/core/PostCompiler.java b/src/core/lombok/core/PostCompiler.java
index e17f806e..72f4b3a2 100644
--- a/src/core/lombok/core/PostCompiler.java
+++ b/src/core/lombok/core/PostCompiler.java
@@ -72,10 +72,12 @@ public final class PostCompiler {
// no need to call super
byte[] original = toByteArray();
byte[] copy = null;
- try {
- copy = applyTransformations(original, fileName, diagnostics);
- } catch (Exception e) {
- diagnostics.addWarning(String.format("Error during the transformation of '%s'; no post-compilation has been applied", fileName));
+ if (original.length > 0) {
+ try {
+ copy = applyTransformations(original, fileName, diagnostics);
+ } catch (Exception e) {
+ diagnostics.addWarning(String.format("Error during the transformation of '%s'; no post-compilation has been applied", fileName));
+ }
}
if (copy == null) {
diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java
index 94fd21d9..1c4437d7 100644
--- a/src/core/lombok/core/handlers/HandlerUtil.java
+++ b/src/core/lombok/core/handlers/HandlerUtil.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
import lombok.AllArgsConstructor;
import lombok.ConfigurationKeys;
@@ -76,7 +77,7 @@ public class HandlerUtil {
return 43;
}
- public static final List<String> NONNULL_ANNOTATIONS, BASE_COPYABLE_ANNOTATIONS, COPY_TO_SETTER_ANNOTATIONS, JACKSON_COPY_TO_BUILDER_ANNOTATIONS;
+ public static final List<String> NONNULL_ANNOTATIONS, BASE_COPYABLE_ANNOTATIONS, COPY_TO_SETTER_ANNOTATIONS, COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS, JACKSON_COPY_TO_BUILDER_ANNOTATIONS;
static {
NONNULL_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
"androidx.annotation.NonNull",
@@ -312,10 +313,24 @@ public class HandlerUtil {
"org.netbeans.api.annotations.common.NullAllowed",
}));
COPY_TO_SETTER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
+ "com.fasterxml.jackson.annotation.JacksonInject",
+ "com.fasterxml.jackson.annotation.JsonAlias",
+ "com.fasterxml.jackson.annotation.JsonFormat",
+ "com.fasterxml.jackson.annotation.JsonIgnore",
+ "com.fasterxml.jackson.annotation.JsonIgnoreProperties",
"com.fasterxml.jackson.annotation.JsonProperty",
"com.fasterxml.jackson.annotation.JsonSetter",
+ "com.fasterxml.jackson.annotation.JsonSubTypes",
+ "com.fasterxml.jackson.annotation.JsonTypeInfo",
+ "com.fasterxml.jackson.annotation.JsonView",
+ "com.fasterxml.jackson.databind.annotation.JsonDeserialize",
+ "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty",
+ }));
+ COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
+ "com.fasterxml.jackson.annotation.JsonAnySetter",
}));
JACKSON_COPY_TO_BUILDER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
+ "com.fasterxml.jackson.annotation.JsonAutoDetect",
"com.fasterxml.jackson.annotation.JsonFormat",
"com.fasterxml.jackson.annotation.JsonIgnoreProperties",
"com.fasterxml.jackson.annotation.JsonIgnoreType",
@@ -351,6 +366,7 @@ public class HandlerUtil {
public static String autoSingularize(String plural) {
return Singulars.autoSingularize(plural);
}
+
public static void handleFlagUsage(LombokNode<?, ?, ?> node, ConfigurationKey<FlagUsageType> key, String featureName) {
FlagUsageType fut = node.getAst().readConfiguration(key);
@@ -728,4 +744,16 @@ public class HandlerUtil {
}
return b.toString();
}
+
+ /** Matches any of the 8 primitive wrapper names, such as {@code Boolean}. */
+ private static final Pattern PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN = Pattern.compile("^(?:java\\.lang\\.)?(?:Boolean|Byte|Short|Integer|Long|Float|Double|Character)$");
+
+ public static int defaultEqualsAndHashcodeIncludeRank(String typeName) {
+ // Modification in this code should be documented
+ // 1. In the changelog this should be marked as an INPROBABLE BREAKING CHANGE, since the hashcode will change
+ // 2. In the javadoc of EqualsAndHashcode.Include#rank
+ if (JavaIdentifiers.isPrimitive(typeName)) return 1000;
+ if (PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN.matcher(typeName).matches()) return 800;
+ return 0;
+ }
}
diff --git a/src/core/lombok/core/handlers/InclusionExclusionUtils.java b/src/core/lombok/core/handlers/InclusionExclusionUtils.java
index 368b51fc..0aa6c47b 100644
--- a/src/core/lombok/core/handlers/InclusionExclusionUtils.java
+++ b/src/core/lombok/core/handlers/InclusionExclusionUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 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
@@ -76,11 +76,13 @@ public class InclusionExclusionUtils {
private final L node;
private final I inc;
private final boolean defaultInclude;
+ private final boolean explicitRank;
- public Included(L node, I inc, boolean defaultInclude) {
+ public Included(L node, I inc, boolean defaultInclude, boolean explicitRank) {
this.node = node;
this.inc = inc;
this.defaultInclude = defaultInclude;
+ this.explicitRank = explicitRank;
}
public L getNode() {
@@ -94,6 +96,10 @@ public class InclusionExclusionUtils {
public boolean isDefaultInclude() {
return defaultInclude;
}
+
+ public boolean hasExplicitRank() {
+ return explicitRank;
+ }
}
private static String innerAnnName(Class<? extends Annotation> type) {
@@ -106,7 +112,7 @@ public class InclusionExclusionUtils {
return name;
}
- public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N, I extends Annotation> List<Included<L, I>> handleIncludeExcludeMarking(Class<I> inclType, String replaceName, Class<? extends Annotation> exclType, LombokNode<A, L, N> typeNode, AnnotationValues<?> annotation, LombokNode<A, L, N> annotationNode, boolean includeTransient) {
+ private static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N, I extends Annotation> List<Included<L, I>> handleIncludeExcludeMarking(Class<I> inclType, String replaceName, Class<? extends Annotation> exclType, LombokNode<A, L, N> typeNode, AnnotationValues<?> annotation, LombokNode<A, L, N> annotationNode, boolean includeTransient) {
List<String> oldExcludes = (annotation != null && annotation.isExplicit("exclude")) ? annotation.getAsStringList("exclude") : null;
List<String> oldIncludes = (annotation != null && annotation.isExplicit("of")) ? annotation.getAsStringList("of") : null;
@@ -118,9 +124,6 @@ public class InclusionExclusionUtils {
if (typeNode == null || typeNode.getKind() != Kind.TYPE) return null;
checkForBogusFieldNames(typeNode, annotation, oldExcludes, oldIncludes);
- String inclTypeName = innerAnnName(inclType);
- String exclTypeName = innerAnnName(exclType);
-
if (oldExcludes != null && oldIncludes != null) {
oldExcludes = null;
if (annotation != null) annotation.setWarning("exclude", "exclude and of are mutually exclusive; the 'exclude' parameter will be ignored.");
@@ -134,7 +137,7 @@ public class InclusionExclusionUtils {
if (markExclude || markInclude != null) memberAnnotationMode = true;
if (markInclude != null && markExclude) {
- child.addError("@" + exclTypeName + " and @" + inclTypeName + " are mutually exclusive; the @Include annotation will be ignored");
+ child.addError("@" + innerAnnName(exclType) + " and @" + innerAnnName(inclType) + " are mutually exclusive; the @Include annotation will be ignored");
markInclude = null;
}
@@ -157,20 +160,20 @@ public class InclusionExclusionUtils {
I inc = markInclude.getInstance();
if (child.getKind() == Kind.METHOD) {
if (child.countMethodParameters() > 0) {
- child.addError("Methods included with @" + inclTypeName + " must have no arguments; it will not be included");
+ child.addError("Methods included with @" + innerAnnName(inclType) + " must have no arguments; it will not be included");
continue;
}
String n = replaceName != null ? markInclude.getAsString(replaceName) : "";
if (n.isEmpty()) n = name;
namesToAutoExclude.add(n);
}
- members.add(new Included<L, I>(child, inc, false));
+ members.add(new Included<L, I>(child, inc, false, markInclude.isExplicit("rank")));
continue;
}
if (onlyExplicitlyIncluded) continue;
if (oldIncludes != null) {
- if (child.getKind() == Kind.FIELD && oldIncludes.contains(name)) members.add(new Included<L, I>(child, null, false));
+ if (child.getKind() == Kind.FIELD && oldIncludes.contains(name)) members.add(new Included<L, I>(child, null, false, false));
continue;
}
if (child.getKind() != Kind.FIELD) continue;
@@ -178,7 +181,7 @@ public class InclusionExclusionUtils {
if (child.isTransient() && !includeTransient) continue;
if (name.startsWith("$")) continue;
if (child.isEnumMember()) continue;
- members.add(new Included<L, I>(child, null, true));
+ members.add(new Included<L, I>(child, null, true, false));
}
/* delete default-included fields with the same name as an explicit inclusion */ {
@@ -207,22 +210,37 @@ public class InclusionExclusionUtils {
@Override public int compare(Included<L, ToString.Include> a, Included<L, ToString.Include> b) {
int ra = a.getInc() == null ? 0 : a.getInc().rank();
int rb = b.getInc() == null ? 0 : b.getInc().rank();
- if (ra < rb) return +1;
- if (ra > rb) return -1;
-
- int pa = a.getNode().getStartPos();
- int pb = b.getNode().getStartPos();
-
- if (pa < pb) return -1;
- if (pa > pb) return +1;
-
- return 0;
+
+ return compareRankOrPosition(ra, rb, a.getNode(), b.getNode());
}
});
return members;
}
public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> List<Included<L, EqualsAndHashCode.Include>> handleEqualsAndHashCodeMarking(LombokNode<A, L, N> typeNode, AnnotationValues<EqualsAndHashCode> annotation, LombokNode<A, L, N> annotationNode) {
- return handleIncludeExcludeMarking(EqualsAndHashCode.Include.class, "replaces", EqualsAndHashCode.Exclude.class, typeNode, annotation, annotationNode, false);
+ List<Included<L, EqualsAndHashCode.Include>> members = handleIncludeExcludeMarking(EqualsAndHashCode.Include.class, "replaces", EqualsAndHashCode.Exclude.class, typeNode, annotation, annotationNode, false);
+
+ Collections.sort(members, new Comparator<Included<L, EqualsAndHashCode.Include>>() {
+ @Override public int compare(Included<L, EqualsAndHashCode.Include> a, Included<L, EqualsAndHashCode.Include> b) {
+ int ra = a.hasExplicitRank() ? a.getInc().rank() : HandlerUtil.defaultEqualsAndHashcodeIncludeRank(a.node.fieldOrMethodBaseType());
+ int rb = b.hasExplicitRank() ? b.getInc().rank() : HandlerUtil.defaultEqualsAndHashcodeIncludeRank(b.node.fieldOrMethodBaseType());
+
+ return compareRankOrPosition(ra, rb, a.getNode(), b.getNode());
+ }
+ });
+ return members;
+ }
+
+ private static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> int compareRankOrPosition(int ra, int rb, LombokNode<A, L, N> nodeA, LombokNode<A, L, N> nodeB) {
+ if (ra < rb) return +1;
+ if (ra > rb) return -1;
+
+ int pa = nodeA.getStartPos();
+ int pb = nodeB.getStartPos();
+
+ if (pa < pb) return -1;
+ if (pa > pb) return +1;
+
+ return 0;
}
}
diff --git a/src/core/lombok/eclipse/EclipseAST.java b/src/core/lombok/eclipse/EclipseAST.java
index e724fb50..d53856af 100644
--- a/src/core/lombok/eclipse/EclipseAST.java
+++ b/src/core/lombok/eclipse/EclipseAST.java
@@ -318,6 +318,7 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
Field f = EcjReflectionCheck.typeReferenceAnnotations;
if (f == null) return null;
annss = (Annotation[][]) f.get(tr);
+ if (annss == null) return null;
return annss[annss.length - 1];
} catch (Throwable t) {
return null;
@@ -349,7 +350,7 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
if (!changed) clearChanged();
}
- private static boolean isComplete(CompilationUnitDeclaration unit) {
+ public static boolean isComplete(CompilationUnitDeclaration unit) {
return (unit.bits & ASTNode.HasAllMethodBodies) != 0;
}
diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java
index 9db491f5..12e9ccdb 100644
--- a/src/core/lombok/eclipse/EclipseNode.java
+++ b/src/core/lombok/eclipse/EclipseNode.java
@@ -23,10 +23,6 @@ package lombok.eclipse;
import java.util.List;
-import lombok.core.AnnotationValues;
-import lombok.core.AST.Kind;
-import lombok.eclipse.handlers.EclipseHandlerUtil;
-
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -36,11 +32,16 @@ import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Statement;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import lombok.core.AST.Kind;
+import lombok.core.AnnotationValues;
+import lombok.eclipse.handlers.EclipseHandlerUtil;
+
/**
* Eclipse specific version of the LombokNode class.
*/
@@ -264,6 +265,39 @@ public class EclipseNode extends lombok.core.LombokNode<EclipseAST, EclipseNode,
return (ClassFileConstants.AccFinal & f) != 0;
}
+ @Override public boolean isPrimitive() {
+ if (node instanceof FieldDeclaration && !isEnumMember()) {
+ return Eclipse.isPrimitive(((FieldDeclaration) node).type);
+ }
+ if (node instanceof MethodDeclaration) {
+ return Eclipse.isPrimitive(((MethodDeclaration) node).returnType);
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public String fieldOrMethodBaseType() {
+ TypeReference typeReference = null;
+ if (node instanceof FieldDeclaration && !isEnumMember()) {
+ typeReference = ((FieldDeclaration) node).type;
+ }
+ if (node instanceof MethodDeclaration) {
+ typeReference = ((MethodDeclaration) node).returnType;
+ }
+ if (typeReference == null) return null;
+
+ String fqn = Eclipse.toQualifiedName(typeReference.getTypeName());
+ if (typeReference.dimensions() == 0) return fqn;
+ StringBuilder result = new StringBuilder(fqn.length() + 2 * typeReference.dimensions());
+ result.append(fqn);
+ for (int i = 0; i < typeReference.dimensions(); i++) {
+ result.append("[]");
+ }
+ return result.toString();
+ }
+
@Override public boolean isTransient() {
if (getKind() != Kind.FIELD) return false;
Integer i = getModifiers();
diff --git a/src/core/lombok/eclipse/TransformEclipseAST.java b/src/core/lombok/eclipse/TransformEclipseAST.java
index 6fcde937..59a0709e 100644
--- a/src/core/lombok/eclipse/TransformEclipseAST.java
+++ b/src/core/lombok/eclipse/TransformEclipseAST.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
@@ -24,6 +24,9 @@ package lombok.eclipse;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
import lombok.ConfigurationKeys;
import lombok.core.LombokConfiguration;
@@ -63,6 +66,7 @@ public class TransformEclipseAST {
public static boolean disableLombok = false;
private static final HistogramTracker lombokTracker;
+ priv