[英]IntelliJ shortcut for inserting a null check?
Is there a shortcut for inserting the code: 是否有插入代码的快捷方式:
if (someParameter == null)
throw NullPointerException("someParameter is null");
Try typing ifn
followed by Tab. 尝试输入
ifn
后跟Tab。 You can find more of those or define your own by going to the preferences and searching for "Live Templates". 您可以通过转到首选项并搜索“实时模板”来查找更多这些内容或定义自己的内容。
IntelliJ IDEA provides another functionality, similar to shortcuts, that can help with your productivity, namely, Postfix completion . IntelliJ IDEA提供了另一种类似于快捷方式的功能,可以帮助您提高工作效率,即Postfix完成 。
If you want to insert a null check, type '.null' after the variable name, eg 如果要插入空检查,请在变量名后键入“.null”,例如
and the null-checking code will be inserted automatically, eg 并且将自动插入空检查代码,例如
IntelliJ IDEA provides more handy postfix completions, which you can find in Preferences at Editor > General > Postfix Completion IntelliJ IDEA提供了更多方便的后缀完成,您可以在编辑器中的首选项>常规>后缀完成中找到它
现在有一种简单的方法(在版本13.1中),如下所述: http : //blog.jetbrains.com/idea/2014/03/postfix-completion/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.