Add targets for org.pkl.core.util.Nullable (#235)

Also, change `java.time.@Nullable Duration` to `@Nullable java.time.Duration` to reduce the chance
of false positive errors in IDEs.
This commit is contained in:
translatenix
2024-02-23 07:07:08 -08:00
committed by GitHub
parent 7f404fff49
commit 32bc75bf50
4 changed files with 12 additions and 6 deletions
@@ -48,7 +48,7 @@ public final class EvaluatorBuilder {
private final Map<String, String> externalProperties = new HashMap<>(); private final Map<String, String> externalProperties = new HashMap<>();
private java.time.@Nullable Duration timeout; private @Nullable java.time.Duration timeout;
private @Nullable Path moduleCacheDir = IoUtils.getDefaultModuleCacheDir(); private @Nullable Path moduleCacheDir = IoUtils.getDefaultModuleCacheDir();
@@ -343,7 +343,7 @@ public final class EvaluatorBuilder {
/** /**
* Sets an evaluation timeout to be enforced by the {@link Evaluator}'s {@code evaluate} methods. * Sets an evaluation timeout to be enforced by the {@link Evaluator}'s {@code evaluate} methods.
*/ */
public EvaluatorBuilder setTimeout(java.time.@Nullable Duration timeout) { public EvaluatorBuilder setTimeout(@Nullable java.time.Duration timeout) {
this.timeout = timeout; this.timeout = timeout;
return this; return this;
} }
@@ -2169,7 +2169,7 @@ public final class AstBuilder extends AbstractAstBuilder<Object> {
return builder; return builder;
} }
private FrameDescriptor.@Nullable Builder createFrameDescriptorBuilder(ObjectBodyContext ctx) { private @Nullable FrameDescriptor.Builder createFrameDescriptorBuilder(ObjectBodyContext ctx) {
if (ctx.ps.isEmpty()) return null; if (ctx.ps.isEmpty()) return null;
checkCommaSeparatedElements(ctx, ctx.ps, ctx.errs); checkCommaSeparatedElements(ctx, ctx.ps, ctx.errs);
@@ -67,7 +67,7 @@ public final class Project {
public static Project loadFromPath( public static Project loadFromPath(
Path path, Path path,
SecurityManager securityManager, SecurityManager securityManager,
java.time.@Nullable Duration timeout, @Nullable java.time.Duration timeout,
StackFrameTransformer stackFrameTransformer, StackFrameTransformer stackFrameTransformer,
Map<String, String> envVars) { Map<String, String> envVars) {
try (var evaluator = try (var evaluator =
@@ -90,7 +90,7 @@ public final class Project {
/** Convenience method to load a project with the default stack frame transformer. */ /** Convenience method to load a project with the default stack frame transformer. */
public static Project loadFromPath( public static Project loadFromPath(
Path path, SecurityManager securityManager, java.time.@Nullable Duration timeout) { Path path, SecurityManager securityManager, @Nullable java.time.Duration timeout) {
return loadFromPath( return loadFromPath(
path, securityManager, timeout, StackFrameTransformers.defaultTransformer, System.getenv()); path, securityManager, timeout, StackFrameTransformers.defaultTransformer, System.getenv());
} }
@@ -20,7 +20,13 @@ import static javax.annotation.meta.When.MAYBE;
import java.lang.annotation.*; import java.lang.annotation.*;
import javax.annotation.meta.TypeQualifierNickname; import javax.annotation.meta.TypeQualifierNickname;
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) @Target({
ElementType.TYPE_PARAMETER,
ElementType.TYPE_USE,
ElementType.PARAMETER,
ElementType.FIELD,
ElementType.METHOD
})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@javax.annotation.Nonnull(when = MAYBE) @javax.annotation.Nonnull(when = MAYBE)