为类成员创建eclipse模板 [英] Create eclipse template for class members
问题描述
所以如果我申报私人会员,例如
So if I declare a private member such as
private MyObject test;
我想创建一个将以以下格式生成代码的模板
I want to create a template that will generate code in the following format
public MyObject retrieveAllMyObjects() {
return test.findAll();
}
我一直在弄乱模板,但我甚至无法弄清楚如何激活模板。当我做Ctrl + Space我只是没有模板提案消息
I have been messing around with the templates but I can't even figure out how to activate the templates. when I do the Ctrl+Space i just get no template proposals message
public ${return_type} retrieveAll${field}s() {
}
显然这只是一个起点,我是只是试图看看我是否可以得到eclipse来生成这个,然后我会从那里去,但没有这样的运气。我的模板不会显示在任何地方。使用的上下文是Java类型成员我做错了什么?
Obviously this is just a starting point, i was just trying to see if i could get eclipse to generate this and then I would go from there, but no such luck. My template doesn't show up anywhere. The context im using is "Java Type Members" what am I doing wrong??
推荐答案
也许你对这个解决方案感到满意:
Maybe you are happy with this solution:
private ${type} ${name};
public ${type} retrieveAll${type}s() {
return ${name}.findAll();
}
如何使用它:
- 设置名称为retrieveAll的代码模板
- 转到你的课程
- 输入'ret '
- 点击
< ctrl> +< space>
- select retrieveAll
-
-
< Enter>
- 键入所需的类型,例如字符串
-
< Tab>
- 键入所需的字段名称,测试
-
< Enter>
- Set up a code template with name 'retrieveAll'
- Go to your class
- type 'ret'
- hit
<ctrl>+<space>
- select retrieveAll
<Enter>
- type your desired Type, e.g. String
<Tab>
- type your desired field name, e.g. test
<Enter>
这篇关于为类成员创建eclipse模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!