在包上使用@ParametersAreNonnullByDefault 注释时,IntelliJ 是否可以自动生成代码以进行空检查参数 [英] Can IntelliJ auto-generate code to null-check arguments when using @ParametersAreNonnullByDefault annotation on package

查看:20
本文介绍了在包上使用@ParametersAreNonnullByDefault 注释时,IntelliJ 是否可以自动生成代码以进行空检查参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢 IntelliJ 可以自动生成代码以在运行时检查传递给方法的每个参数/参数是否为 null 的功能.

此功能在Preferences > Build, Execution, Deployment > Compiler > 为notnull-annotated方法添加运行时断言和参数(复选框).相邻的 Configure annotations 按钮配置哪个注释包.

我正在尝试在包级别设置我的非空注释.示例:

@ParametersAreNonnullByDefault包 work.basil.ticktock.backend.data;导入 javax.annotation.ParametersAreNonnullByDefault;

我的问题是:这些配置注释"中的哪些(如果有)适用于 @ParametersAreNonnullByDefault 注释的生成代码

解决方案

请关注/评论已在 YouTrack 上创建但尚未实施的重复功能请求:https://youtrack.jetbrains.com/issue/IDEA-164347.谢谢.

I like the feature where IntelliJ can automatically generate code to check at runtime for null on each argument/parameter passed to a method.

This feature is enabled in Preferences > Build, Execution, Deployment > Compiler > Add runtime assertions for notnull-annotated methods and parameters (checkbox). The neighboring Configure annotations button configures which annotation package.

I am trying to set my not-null annotation at the package level. Example:

@ParametersAreNonnullByDefault
package work.basil.ticktock.backend.data;

import javax.annotation.ParametersAreNonnullByDefault;

My question is: Which, if any, of these "Configure annotations" work the generate code for the @ParametersAreNonnullByDefault annotation discussed here and found here?

The null-checks are indeed working within the code editor, generating warnings. But I want runtime-checking as provided by the checkbox shown in this screenshot.

解决方案

Please follow/comment the duplicated feature request already created at YouTrack, but not yet implemented: https://youtrack.jetbrains.com/issue/IDEA-164347. Thank you.

这篇关于在包上使用@ParametersAreNonnullByDefault 注释时,IntelliJ 是否可以自动生成代码以进行空检查参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆