diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-09-17 23:44:26 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-09-18 01:21:33 +0200 |
commit | 9198551defb7dd71d872c7b86af0a3f0bf0ec545 (patch) | |
tree | 7669f792959f1b5632c8870ef2550f95313ea52c /src/core/lombok/eclipse/handlers/HandleNonNull.java | |
parent | d7873f2d21564e8e7f22409fe03681d7dd4c8c1e (diff) | |
download | lombok-9198551defb7dd71d872c7b86af0a3f0bf0ec545.tar.gz lombok-9198551defb7dd71d872c7b86af0a3f0bf0ec545.tar.bz2 lombok-9198551defb7dd71d872c7b86af0a3f0bf0ec545.zip |
Finishing work on making lombok do sensible things with TYPE_USE annotations and for example their use on the typearg in a collection type which is being `@Singular`-ized.
Diffstat (limited to 'src/core/lombok/eclipse/handlers/HandleNonNull.java')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleNonNull.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleNonNull.java b/src/core/lombok/eclipse/handlers/HandleNonNull.java index d09993ed..ebc62909 100644 --- a/src/core/lombok/eclipse/handlers/HandleNonNull.java +++ b/src/core/lombok/eclipse/handlers/HandleNonNull.java @@ -58,7 +58,26 @@ import org.mangosdk.spi.ProviderFor; @ProviderFor(EclipseAnnotationHandler.class) @HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first. public class HandleNonNull extends EclipseAnnotationHandler<NonNull> { + public static final HandleNonNull INSTANCE = new HandleNonNull(); + + public void fix(EclipseNode method) { + for (EclipseNode m : method.down()) { + if (m.getKind() != Kind.ARGUMENT) continue; + for (EclipseNode c : m.down()) { + if (c.getKind() == Kind.ANNOTATION) { + if (annotationTypeMatches(NonNull.class, c)) { + handle0((Annotation) c.get(), c, true); + } + } + } + } + } + @Override public void handle(AnnotationValues<NonNull> annotation, Annotation ast, EclipseNode annotationNode) { + handle0(ast, annotationNode, false); + } + + private void handle0(Annotation ast, EclipseNode annotationNode, boolean force) { handleFlagUsage(annotationNode, ConfigurationKeys.NON_NULL_FLAG_USAGE, "@NonNull"); if (annotationNode.up().getKind() == Kind.FIELD) { @@ -88,7 +107,7 @@ public class HandleNonNull extends EclipseAnnotationHandler<NonNull> { return; } - if (isGenerated(declaration)) return; + if (!force && isGenerated(declaration)) return; if (declaration.isAbstract()) { // This used to be a warning, but as @NonNull also has a documentary purpose, better to not warn about this. Since 1.16.7 |