Skip to content

Commit

Permalink
Merge pull request #3330 from Rawi01/eclipse-record-tests
Browse files Browse the repository at this point in the history
Inject fields after generated record fields
  • Loading branch information
rzwitserloot authored Jan 19, 2023
2 parents 75c9a9d + b718fbf commit d3a05b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ public static EclipseNode injectField(EclipseNode type, FieldDeclaration field)
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);
Expand Down Expand Up @@ -2760,6 +2760,13 @@ public static boolean isRecordField(EclipseNode fieldNode) {
return fieldNode.getKind() == Kind.FIELD && (((FieldDeclaration) fieldNode.get()).modifiers & AccRecord) != 0;
}

/**
* 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`).
*/
Expand Down
4 changes: 2 additions & 2 deletions test/transform/resource/after-ecj/LoggerFloggerRecord.java
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/transform/resource/after-ecj/LoggerSlf4jOnRecord.java
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/transform/resource/after-ecj/SynchronizedInRecord.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit d3a05b5

Please sign in to comment.