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

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

问题描述

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

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

Preferences> Build, Execution, Deployment> Compiler> Add runtime assertions for notnull-annotated methods and parameters中启用此功能(复选框).相邻的Configure annotations按钮配置哪个注释包.

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;

我的问题是:这些配置注释"中的哪个(如果有的话)为@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.

推荐答案

请关注/评论在YouTrack已创建但尚未实现的重复功能请求:

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天全站免登陆