如何处理骆驼案例的Eclipse模板? [英] How to deal with Camel Case for Eclipse Templates?

查看:88
本文介绍了如何处理骆驼案例的Eclipse模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个Eclipse模板,它将在创建一个属性时创建getter和setter。我目前的模板是有效的,除了用于吸气器和固定器的骆驼外壳。


private $ {type} $ {field};

private $ {type} get $ {field}(){return $ {field};}



private void设置$ {field}($ {type} $ {field}){this。$ {field} = $ {field};}




<有什么技巧呢?我知道Eclipse可以为我生成getter和setter,但是#1:它是菜单驱动(慢),#2:它不是我想要的格式。



谢谢!

解决方案

最好你现在可以做的是

  private $ {Type} $ {field}; 

private $ {Type} get $ {Field}(){return $ {field};}

private void set $ {Field}($ {Type} $ { field}){this。$ {field} = $ {field};}



您可以在自定义插件中定义VariableResolver来执行此操作


I'm trying to write an Eclipse template which will create getters and setters when I create an attribute. My current template works, except for the camel casing for the getters and setters.

private ${type} ${field};

private ${type} get${field}() {return ${field};}

private void set${field}(${type} ${field}) {this.${field} = ${field};}

Any tricks to do so? I am aware that Eclipse can generate the getters and setters for me, but #1: it's menu driven (slow), #2: it's not in the format I want.

Thanks!

解决方案

Best you can do right now is

private ${Type} ${field};

private ${Type} get${Field}() {return ${field};}

private void set${Field}(${Type} ${field}) {this.${field} = ${field};}

This defines separate linked variables for the upper and lower case names.

You may be able to define a VariableResolver in a custom plugin to do this

这篇关于如何处理骆驼案例的Eclipse模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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