aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/HandleNonNull.java
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-09-10 10:20:12 +0200
committerRawi01 <Rawi01@users.noreply.github.com>2020-09-10 10:32:14 +0200
commit0064c534273d9fb877f7e570f7a430060c88a5fb (patch)
treeee7089c1fbe948127aaea4c3317dd7dc18b0ee39 /src/core/lombok/javac/handlers/HandleNonNull.java
parent9148294f78a8e646ee131ca182a9b692bc028fdb (diff)
downloadlombok-0064c534273d9fb877f7e570f7a430060c88a5fb.tar.gz
lombok-0064c534273d9fb877f7e570f7a430060c88a5fb.tar.bz2
lombok-0064c534273d9fb877f7e570f7a430060c88a5fb.zip
Add record support
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleNonNull.java')
-rw-r--r--src/core/lombok/javac/handlers/HandleNonNull.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java
index 079d5b04..6b6b7efa 100644
--- a/src/core/lombok/javac/handlers/HandleNonNull.java
+++ b/src/core/lombok/javac/handlers/HandleNonNull.java
@@ -51,17 +51,23 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Name;
+import lombok.AccessLevel;
import lombok.ConfigurationKeys;
import lombok.NonNull;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
+
+import lombok.javac.Java14Flags;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.javac.handlers.HandleConstructor.SkipIfConstructorExists;
@ProviderFor(JavacAnnotationHandler.class)
@HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first.
public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
+ private HandleConstructor handleConstructor = new HandleConstructor();
+
@Override public void handle(AnnotationValues<NonNull> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.NON_NULL_FLAG_USAGE, "@NonNull");
@@ -119,6 +125,15 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
return;
}
+ JavacNode typeNode = upToTypeNode(annotationNode);
+
+ if ((declaration.mods.flags & Java14Flags.RECORD) != 0) {
+ if (!lombokConstructorExists(typeNode)) {
+ handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, null, SkipIfConstructorExists.NO, annotationNode);
+ }
+ return;
+ }
+
List<JCStatement> statements = declaration.body.stats;
String expectedName = paramNode.getName();