加上这个。 IntelliJ Idea中的成员变量/方法 [英] Add this. to member variables/methods in IntelliJ Idea

查看:1590
本文介绍了加上这个。 IntelliJ Idea中的成员变量/方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ Idea中是否有办法强制执行此操作。要自动放入格式代码或保存,或者至少显示错误,如果它应该在那里?

Is there a way in IntelliJ Idea to force this. to be automatically placed into code on a format or save or at the very least show an error if it should be in there?

推荐答案

您可以打开以下检查:


  • 文件>设置> [项目设置]>检查>代码样式问题>

    • 实例方法调用未通过'this'限定

    • 实例字段访问权限未通过'this'限定

    这将突出显示任何遗漏的'this。'声明。将光标放在突出显示上,Alt + Enter将显示快速修复以添加this。如果在初始弹出窗口中向右箭头,则可以选择修复所有实例方法调用不符合'这个问题选项可以修复当前文件中的所有问题。(你需要为方法和字段执行此操作)

    That will highlight any missing 'this.' declarations. With your cursor on the highlight, Alt+Enter will bring up the quick fix to add 'this". If on that initial pop-up you arrow to the right, You can select the "Fix All "Instance Method call not qualified with 'this'" problems" option to fix all issues in the current file. (you'll need to do this for both methods and fields)

    如果你运行检查项目 - 通过分析>检查代码... 或通过分析>按名称运行检查... 选项,然后您可以将修复程序应用于所有文件项目(或模块或包等)

    If you run the inspection on the project - either by the Analyze > Inspect Code... or by the Analyze > Run Inspection by Name... option you can then apply the fix to all files in the project (or module or package, etc.)

    无法在重新格式化时获得快速修复。

    There is no way to get the quick fix to occur on a reformat.

    这篇关于加上这个。 IntelliJ Idea中的成员变量/方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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