更改实现接口方法生成的方法的默认主体 [英] Changing default body for methods generated from implementing interface methods

查看:305
本文介绍了更改实现接口方法生成的方法的默认主体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ在选择此对话框时创建具有默认实现的方法:

IntelliJ creates methods with a default implementation when selecting this dialog:

如果方法的返回类型为void,则该方法为空,否则该方法返回返回类型的默认值:

If the method's return type is void, the method is empty, otherwise the method returns the default value for the return type:

如何将生成的方法更改为如下所示:

How can I change the generated methods to look like this:

我已经尝试更改
设置>下的文件和代码模板New Method Body ;编辑>默认和项目方案的文件和代码模板,但没有改变任何东西,方法像以前一样生成:

I already tried changing the File and Code Template "New Method Body" under Settings > Editor > File and Code Templates for both the default and project scheme, but that didn't change anything, the methods are generated like before:

< a href =https://i.stack.imgur.com/pAfiF.png =nofollow noreferrer>

我缺少什么,我需要更改什么?

What am I missing, what do I have to change?

推荐答案

实施方法操作的模板位于已实施方法主体(设置>编辑器>文件和代码模板>标签代码)。

The template for the Implement methods action is located under the point Implemented Method Body (Settings > Editor > File and Code Templates > Tab Code).

新方法主体模板适用于创建方法操作:

这篇关于更改实现接口方法生成的方法的默认主体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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