aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2023-01-19 22:50:31 +0100
committerGitHub <noreply@github.com>2023-01-19 22:50:31 +0100
commitd3a05b574bd370511726193df619bc03afaaf059 (patch)
treedf090ef9a1d3f128c68150bfa5340d1a99502878
parent75c9a9ddde2b61273ae21efbfce91d4dde533d89 (diff)
parentb718fbf4975bb8fa2f33e8533cde77ad7899e3df (diff)
downloadlombok-d3a05b574bd370511726193df619bc03afaaf059.tar.gz
lombok-d3a05b574bd370511726193df619bc03afaaf059.tar.bz2
lombok-d3a05b574bd370511726193df619bc03afaaf059.zip
Merge pull request #3330 from Rawi01/eclipse-record-tests
Inject fields after generated record fields
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java9
-rw-r--r--test/transform/resource/after-ecj/LoggerFloggerRecord.java4
-rw-r--r--test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java4
-rw-r--r--test/transform/resource/after-ecj/SynchronizedInRecord.java4
4 files changed, 14 insertions, 7 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 072b6df2..9af88937 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -1998,7 +1998,7 @@ public class EclipseHandlerUtil {
int index = 0;
for (; index < size; index++) {
FieldDeclaration f = newArray[index];
- if (isEnumConstant(f) || isGenerated(f)) continue;
+ if (isEnumConstant(f) || isGenerated(f) || isRecordField(f)) continue;
break;
}
System.arraycopy(newArray, index, newArray, index + 1, size - index);
@@ -2761,6 +2761,13 @@ public class EclipseHandlerUtil {
}
/**
+ * Returns {@code true} If the provided node is a field declaration, and represents a field in a {@code record} declaration.
+ */
+ public static boolean isRecordField(FieldDeclaration fieldDeclaration) {
+ return (fieldDeclaration.modifiers & AccRecord) != 0;
+ }
+
+ /**
* Returns {@code true) if the provided node is a type declaration <em>and</em> is <strong>not</strong> of any kind indicated by the flags (the intent is to pass flags usch as `ClassFileConstants.AccEnum`).
*/
static boolean isTypeAndDoesNotHaveFlags(EclipseNode typeNode, long flags) {
diff --git a/test/transform/resource/after-ecj/LoggerFloggerRecord.java b/test/transform/resource/after-ecj/LoggerFloggerRecord.java
index fde69e74..dc64c335 100644
--- a/test/transform/resource/after-ecj/LoggerFloggerRecord.java
+++ b/test/transform/resource/after-ecj/LoggerFloggerRecord.java
@@ -1,9 +1,9 @@
// version 19:
import lombok.extern.flogger.Flogger;
class LoggerFloggerRecord {
- public @Flogger record Inner(com log) {
- private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
+ public @Flogger record Inner(String x) {
/* Implicit */ private final String x;
+ private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
<clinit>() {
}
public Inner(String x) {
diff --git a/test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java b/test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java
index 673f83a3..91343ff2 100644
--- a/test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java
+++ b/test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java
@@ -1,9 +1,9 @@
// version 14:
import lombok.extern.slf4j.Slf4j;
-public @Slf4j record LoggerSlf4jOnRecord(org log, String a) {
- private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jOnRecord.class);
+public @Slf4j record LoggerSlf4jOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
+ private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jOnRecord.class);
<clinit>() {
}
public LoggerSlf4jOnRecord(String a, String b) {
diff --git a/test/transform/resource/after-ecj/SynchronizedInRecord.java b/test/transform/resource/after-ecj/SynchronizedInRecord.java
index b4dc3770..4b586f3f 100644
--- a/test/transform/resource/after-ecj/SynchronizedInRecord.java
+++ b/test/transform/resource/after-ecj/SynchronizedInRecord.java
@@ -1,8 +1,8 @@
import lombok.Synchronized;
-public record SynchronizedInRecord(java $lock, String a) {
- private final java.lang.Object $lock = new java.lang.Object[0];
+public record SynchronizedInRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
+ private final java.lang.Object $lock = new java.lang.Object[0];
public SynchronizedInRecord(String a, String b) {
super();
.a = a;