我想在 Eclipse 中为 Java 类创建一个构造函数模板。我有一个适用于大多数课程的版本。尽管它不适用于嵌套在其他类中的类。 (见类Inner
如下)如何获得类名的简短版本?
模板不起作用
public ${newType:enclosing_type}() {
${cursor}
}
不及格班级示例
public class Outer {
public class Inner {
// Current template expands to the following
public Outer.Inner() {
}
}
}
我查了一下靛蓝。你不能。据我所知,您唯一的选择是在模板列表中引入一个新变量,以便获取没有外部类名称的内部类名称。
如果您接受编写一些代码(阅读插件)来实现您的目标的努力,您可以从以下位置开始:
- http://thomaswabner.wordpress.com/2009/08/21/use-your-own-variable-in-eclipse-code-templates/ http://thomaswabner.wordpress.com/2009/08/21/use-your-own-variable-in-eclipse-code-templates/
- 如何将参数传递到 eclipse-plugin 中的代码模板 https://stackoverflow.com/questions/1577505/how-to-pass-parameter-into-code-template-in-eclipse-plugin
- Java 代码模板的 Eclipse 自定义变量 https://stackoverflow.com/questions/350600/eclipse-custom-variable-for-java-code-templates?rq=1
或者如果你像我一样懒,你可以开始下载这个项目:https://github.com/aabeling/template-variables https://github.com/aabeling/template-variables并根据您的需求进行定制。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)