Bob*_*Bob 17 java eclipse templates
在Eclipse 3.5中,在Windows - > Preferences - > Java> Editor - > Templates下,我可以添加代码模板.但是,这些模板只能包含我可以插入到现有Java类中的代码段.
是否可以为整个Java类创建模板,我可以使用File - > New - > My-Java-Class添加它们?
Mic*_*les 21
你能做的是添加一个普通的代码快捷方式(java - > editor - > templates),
即使编辑器模板"newcustomclass"成为您正在讨论的类的内容.
然后以正常方式创建新的java类,删除所有内容,然后使用"newcustomclass"代码模板创建新的自动java类.
这是一个简单异常类的示例:
public class ${enclosing_type} extends Exception {
/**
* Constructs with the given throwable
* @param t the throwable to throw
*/
public ${enclosing_type}(Throwable t) {
super(t);
}
/**
* Constructs with the given message
* @param message the message of the exception
*/
public ${enclosing_type}(String message) {
super(message);
}
/**
* Constructs with the given message and the original throwable cause
* @param message the message of the exception
* @param t the original throwable
*/
public ${enclosing_type}(String message, Throwable t) {
super(message, t);
}
}
Run Code Online (Sandbox Code Playgroud)
是! 窗口 - >首选项 - > Java - >代码样式 - >代码模板
在树面板中选择"代码"和新的Java文件.
| 归档时间: |
|
| 查看次数: |
18402 次 |
| 最近记录: |