Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable @Getter on a Java record #3548

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Maarten Mulders <[email protected]>
Mark Haynes <[email protected]>
Mart Hagenaars <[email protected]>
Mateusz Matela <[email protected]>
Mat Jaggard <[email protected]>
Martin O'Connor <[email protected]>
Michael Dardis <[email protected]>
Michael Ernst <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions src/core/lombok/eclipse/handlers/HandleGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
@Provides
public class HandleGetter extends EclipseAnnotationHandler<Getter> {
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0];
private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, an enum, or a field.";
private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, a record, an enum, or a field.";

public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelGetter, List<Annotation> onMethod) {
if (checkForTypeLevelGetter) {
Expand All @@ -92,7 +92,7 @@ public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, Acce
}
}

if (!isClassOrEnum(typeNode)) {
if (!isClassEnumOrRecord(typeNode)) {
pos.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/lombok/javac/handlers/HandleGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
*/
@Provides
public class HandleGetter extends JavacAnnotationHandler<Getter> {
private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, an enum, or a field.";
private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, a record, an enum, or a field.";

public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelGetter, List<JCAnnotation> onMethod) {
if (checkForTypeLevelGetter) {
Expand All @@ -81,7 +81,7 @@ public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, Acces
}
}

if (!isClassOrEnum(typeNode)) {
if (!isClassEnumOrRecord(typeNode)) {
errorNode.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
Expand Down
9 changes: 9 additions & 0 deletions test/transform/resource/after-delombok/GetterOnRecord.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// version 14:
public record GetterOnRecord(String a, String b) {
@java.lang.SuppressWarnings("all")
public String getA() {
return this.a;
}

@java.lang.SuppressWarnings("all")
public String getB() {
return this.b;
}
}
7 changes: 7 additions & 0 deletions test/transform/resource/after-ecj/GetterOnRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
public @Getter record GetterOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;

public @java.lang.SuppressWarnings("all") String getA() {
return this.a;
}
public @java.lang.SuppressWarnings("all") String getB() {
return this.b;
}
}

This file was deleted.

This file was deleted.

Loading