今天下午闲着没事情做,上网也没什么好做的,想起了MyEclipse里面的代码注释模板确实有点太大众化了点,刚刚过去的那个项目光是复制注释(文件头)就让我出了几次指摘。于是乎做了这个根本我们公司的情况作的一个代码模板。
其实刚把这个codetemplates.xml导出来的时候,我看着也挺傻眼的。XML这块我基本上除了配置过Struts的配置文件以外很少接触过,四处翻资料,弄明白了其实也就那么回事儿,CSDN上某位大大还把他的代码模板给贴了出来了,这让我省了不少理解的功夫。毕竟单纯的理论和有一个实际的东西对照着看的话,要容易理解一点吧。
废话少说,贴下我的模板代码:
代码
1
<?
xml version="1.0" encoding="UTF-8"
?>
2 < templates >
3 < template
4 autoinsert ="false"
5 context ="filecomment_context"
6 deleted ="false"
7 description ="Comment for created Java files"
8 enabled ="true"
9 id ="org.eclipse.jdt.ui.text.codetemplates.filecomment"
10 name ="filecomment" >
11 /**
12 * [Product]
13 * ${project_name}
14 * [Copyright]
15 * Copyright © ${year} ICSS All Rights Reserved.
16 * [FileName]
17 * ${file_name}
18 * [History]
19 * Version Date Author Content
20 * -------- --------- ---------- ------------------------
21 * 1.0.0 ${date} ${user} 最初版本
22 */ </ template >
23 <!-- 类注释 -->
24 < template autoinsert ="false" context ="typecomment_context"
25 deleted ="false" description ="Comment for created types" enabled ="true"
26 id ="org.eclipse.jdt.ui.text.codetemplates.typecomment"
27 name ="typecomment" >
28 /**
29 * < b > Summary: < /b >
30 * TODO 请在此处简要描述此类所实现的功能。因为这项注释主要是为了在IDE环境中生成tip帮助,务必简明扼要
31 * < b > Remarks: < /b >
32 * TODO 请在此处详细描述类的功能、调用方法、注意事项、以及与其它类的关系
33 */ </ template >
34 <!-- 构造函数注释 -->
35 < template
36 autoinsert ="false"
37 context ="constructorcomment_context"
38 deleted ="false"
39 description ="Comment for created constructors"
40 enabled ="true"
41 id ="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"
42 name ="constructorcomment" >
43 /**
44 * < b > Summary: < /b >
45 * 构造一个 ${enclosing_type}
46 * < b > Remarks: < /b >
47 * 构造类 ${enclosing_type} 的构造函数 ${enclosing_type}
48 * ${tags}
49 */ </ template >
50 <!-- GET方法注释 -->
51 < template
52 autoinsert ="false"
53 context ="gettercomment_context"
54 deleted ="false"
55 description ="Comment for getter method"
56 enabled ="true"
57 id ="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
58 name ="gettercomment" >
59 /**
60 * < b > Summary: < /b >
61 * 获取${bare_field_name}的值
62 * @return ${bare_field_name}
63 */ </ template >
64 <!-- SET方法注释 -->
65 < template
66 autoinsert ="true"
67 context ="settercomment_context"
68 deleted ="false"
69 description ="Comment for setter method"
70 enabled ="true"
71 id ="org.eclipse.jdt.ui.text.codetemplates.settercomment"
72 name ="settercomment" >
73 /**
74 * < b > Summary: < /b >
75 * 设置 ${bare_field_name} 的值
76 * @param ${param}
77 */ </ template >
78 <!-- 方法注释 -->
79 < template
80 autoinsert ="false"
81 context ="methodcomment_context"
82 deleted ="false"
83 description ="Comment for non-overriding methods"
84 enabled ="true"
85 id ="org.eclipse.jdt.ui.text.codetemplates.methodcomment"
86 name ="methodcomment" >
87 /**
88 * < b > Summary: < /b >
89 * ${enclosing_method}(请用一句话描述这个方法的作用)
90 * ${tags}
91 */ </ template >
92 <!-- 代理方法注释 -->
93 < template
94 autoinsert ="true"
95 context ="delegatecomment_context"
96 deleted ="false"
97 description ="Comment for delegate methods"
98 enabled ="true"
99 id ="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
100 name ="delegatecomment" >
101 /**
102 * < b > Summary: < /b >
103 * 代理方法 ${enclosing_method}
104 * ${tags}
105 * ${see_to_target}
106 */ </ template >
107 <!-- 复写方法注释 -->
108 < template
109 autoinsert ="true"
110 context ="overridecomment_context"
111 deleted ="false"
112 description ="Comment for overriding methods"
113 enabled ="true"
114 id ="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
115 name ="overridecomment" >
116 /**
117 * < b > Summary: < /b >
118 * 复写方法 ${enclosing_method}
119 * ${tags}
120 * ${see_to_overridden}
121 */ </ template >
122 <!-- 局部变量注释 貌似没用 -->
123 < template
124 autoinsert ="false"
125 context ="fieldcomment_context"
126 deleted ="false"
127 description ="Comment for fields"
128 enabled ="true"
129 id ="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"
130 name ="fieldcomment" >
131 /**
132 * ${field}:${todo}(请用一句话描述这个变量表示什么)
133 */ </ template >
134 </ templates >
2 < templates >
3 < template
4 autoinsert ="false"
5 context ="filecomment_context"
6 deleted ="false"
7 description ="Comment for created Java files"
8 enabled ="true"
9 id ="org.eclipse.jdt.ui.text.codetemplates.filecomment"
10 name ="filecomment" >
11 /**
12 * [Product]
13 * ${project_name}
14 * [Copyright]
15 * Copyright © ${year} ICSS All Rights Reserved.
16 * [FileName]
17 * ${file_name}
18 * [History]
19 * Version Date Author Content
20 * -------- --------- ---------- ------------------------
21 * 1.0.0 ${date} ${user} 最初版本
22 */ </ template >
23 <!-- 类注释 -->
24 < template autoinsert ="false" context ="typecomment_context"
25 deleted ="false" description ="Comment for created types" enabled ="true"
26 id ="org.eclipse.jdt.ui.text.codetemplates.typecomment"
27 name ="typecomment" >
28 /**
29 * < b > Summary: < /b >
30 * TODO 请在此处简要描述此类所实现的功能。因为这项注释主要是为了在IDE环境中生成tip帮助,务必简明扼要
31 * < b > Remarks: < /b >
32 * TODO 请在此处详细描述类的功能、调用方法、注意事项、以及与其它类的关系
33 */ </ template >
34 <!-- 构造函数注释 -->
35 < template
36 autoinsert ="false"
37 context ="constructorcomment_context"
38 deleted ="false"
39 description ="Comment for created constructors"
40 enabled ="true"
41 id ="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"
42 name ="constructorcomment" >
43 /**
44 * < b > Summary: < /b >
45 * 构造一个 ${enclosing_type}
46 * < b > Remarks: < /b >
47 * 构造类 ${enclosing_type} 的构造函数 ${enclosing_type}
48 * ${tags}
49 */ </ template >
50 <!-- GET方法注释 -->
51 < template
52 autoinsert ="false"
53 context ="gettercomment_context"
54 deleted ="false"
55 description ="Comment for getter method"
56 enabled ="true"
57 id ="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
58 name ="gettercomment" >
59 /**
60 * < b > Summary: < /b >
61 * 获取${bare_field_name}的值
62 * @return ${bare_field_name}
63 */ </ template >
64 <!-- SET方法注释 -->
65 < template
66 autoinsert ="true"
67 context ="settercomment_context"
68 deleted ="false"
69 description ="Comment for setter method"
70 enabled ="true"
71 id ="org.eclipse.jdt.ui.text.codetemplates.settercomment"
72 name ="settercomment" >
73 /**
74 * < b > Summary: < /b >
75 * 设置 ${bare_field_name} 的值
76 * @param ${param}
77 */ </ template >
78 <!-- 方法注释 -->
79 < template
80 autoinsert ="false"
81 context ="methodcomment_context"
82 deleted ="false"
83 description ="Comment for non-overriding methods"
84 enabled ="true"
85 id ="org.eclipse.jdt.ui.text.codetemplates.methodcomment"
86 name ="methodcomment" >
87 /**
88 * < b > Summary: < /b >
89 * ${enclosing_method}(请用一句话描述这个方法的作用)
90 * ${tags}
91 */ </ template >
92 <!-- 代理方法注释 -->
93 < template
94 autoinsert ="true"
95 context ="delegatecomment_context"
96 deleted ="false"
97 description ="Comment for delegate methods"
98 enabled ="true"
99 id ="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
100 name ="delegatecomment" >
101 /**
102 * < b > Summary: < /b >
103 * 代理方法 ${enclosing_method}
104 * ${tags}
105 * ${see_to_target}
106 */ </ template >
107 <!-- 复写方法注释 -->
108 < template
109 autoinsert ="true"
110 context ="overridecomment_context"
111 deleted ="false"
112 description ="Comment for overriding methods"
113 enabled ="true"
114 id ="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
115 name ="overridecomment" >
116 /**
117 * < b > Summary: < /b >
118 * 复写方法 ${enclosing_method}
119 * ${tags}
120 * ${see_to_overridden}
121 */ </ template >
122 <!-- 局部变量注释 貌似没用 -->
123 < template
124 autoinsert ="false"
125 context ="fieldcomment_context"
126 deleted ="false"
127 description ="Comment for fields"
128 enabled ="true"
129 id ="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"
130 name ="fieldcomment" >
131 /**
132 * ${field}:${todo}(请用一句话描述这个变量表示什么)
133 */ </ template >
134 </ templates >