Skip to content

Commit d3a05b5

Browse files
authored
Merge pull request #3330 from Rawi01/eclipse-record-tests
Inject fields after generated record fields
2 parents 75c9a9d + b718fbf commit d3a05b5

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ public static EclipseNode injectField(EclipseNode type, FieldDeclaration field)
19981998
int index = 0;
19991999
for (; index < size; index++) {
20002000
FieldDeclaration f = newArray[index];
2001-
if (isEnumConstant(f) || isGenerated(f)) continue;
2001+
if (isEnumConstant(f) || isGenerated(f) || isRecordField(f)) continue;
20022002
break;
20032003
}
20042004
System.arraycopy(newArray, index, newArray, index + 1, size - index);
@@ -2760,6 +2760,13 @@ public static boolean isRecordField(EclipseNode fieldNode) {
27602760
return fieldNode.getKind() == Kind.FIELD && (((FieldDeclaration) fieldNode.get()).modifiers & AccRecord) != 0;
27612761
}
27622762

2763+
/**
2764+
* Returns {@code true} If the provided node is a field declaration, and represents a field in a {@code record} declaration.
2765+
*/
2766+
public static boolean isRecordField(FieldDeclaration fieldDeclaration) {
2767+
return (fieldDeclaration.modifiers & AccRecord) != 0;
2768+
}
2769+
27632770
/**
27642771
* 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`).
27652772
*/

test/transform/resource/after-ecj/LoggerFloggerRecord.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// version 19:
22
import lombok.extern.flogger.Flogger;
33
class LoggerFloggerRecord {
4-
public @Flogger record Inner(com log) {
5-
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
4+
public @Flogger record Inner(String x) {
65
/* Implicit */ private final String x;
6+
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
77
<clinit>() {
88
}
99
public Inner(String x) {

test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// version 14:
22
import lombok.extern.slf4j.Slf4j;
3-
public @Slf4j record LoggerSlf4jOnRecord(org log, String a) {
4-
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jOnRecord.class);
3+
public @Slf4j record LoggerSlf4jOnRecord(String a, String b) {
54
/* Implicit */ private final String a;
65
/* Implicit */ private final String b;
6+
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jOnRecord.class);
77
<clinit>() {
88
}
99
public LoggerSlf4jOnRecord(String a, String b) {

test/transform/resource/after-ecj/SynchronizedInRecord.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import lombok.Synchronized;
2-
public record SynchronizedInRecord(java $lock, String a) {
3-
private final java.lang.Object $lock = new java.lang.Object[0];
2+
public record SynchronizedInRecord(String a, String b) {
43
/* Implicit */ private final String a;
54
/* Implicit */ private final String b;
5+
private final java.lang.Object $lock = new java.lang.Object[0];
66
public SynchronizedInRecord(String a, String b) {
77
super();
88
.a = a;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy