Eclipse設定模板codetemplates
阿新 • • 發佈:2018-11-05
在Window->Preferences->Java->Code Style->Code Templates,
點選"Import",匯入模板codetemplates.xml檔案
具體內容如下:
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method"View Codeenabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment"> 2 /** 3 * ${bare_field_name}. 4 * 5 * @return the ${bare_field_name} 6 * @author ${user} 7 * @Date ${date}${time} <br/> 8 */</template><template autoinsert="false" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment"> 9 /** 10 * ${param}. 11 * 12 * @param ${param} the ${bare_field_name} to set 13 * @author ${user} 14 * @Date ${date}${time} <br/> 15 */</template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/** 16 * Creates a new instance of ${enclosing_type}. 17 * Description: 18 * @author ${user} 19 * @Date ${date}${time} <br> 20 * ${tags} 21 */ 22 </template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/** 23 * Project Name:${project_name} <br> 24 * File Name:${file_name} <br> 25 * Package Name:${package_name} <br> 26 * @author ${user} 27 * Date:${date}${time} <br> 28 * Copyright (c) ${year}, xxxx有限公司 All Rights Reserved. 29 */</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/** 30 * ClassName: ${type_name} <br> 31 * Description: ${todo} <br> 32 * @author ${user} 33 * @Date ${date}${time} <br> 34 * @version 35 */</template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/** 36 * ${field}:${todo}(用一句話描述這個變量表示什麼). 37 */</template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment"> 38 /** 39 * ${enclosing_method}:(這裡用一句話描述這個方法的作用). <br> 40 * 41 * @author ${user} 42 * @Date ${date}${time} <br> 43 * ${tags} 44 */</template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/** 45 * ${todo} 簡單描述該方法的實現功能(可選). 46 * ${see_to_overridden} 47 */</template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/** 48 * ${tags} 49 * ${see_to_target} 50 */</template><template autoinsert="false" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">/** 51 * Project Name:${project_name} <br> 52 * File Name:${file_name} <br> 53 * Package Name:${package_name} <br> 54 * @author ${user} 55 * Date:${date}${time} <br> 56 * Copyright (c) ${year}, xxxx有限公司 All Rights Reserved. 57 */ 58 ${filecomment} 59 60 ${package_declaration} 61 /** 62 * ClassName: ${type_name} <br> 63 * Description: ${todo} 64 * @author ${user} 65 * @Date ${date}${time} <br> 66 * @version 67 */ 68 ${typecomment} 69 ${type_declaration} 70 </template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classbody" name="classbody"> 71 </template><template autoinsert="true" context="interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name="interfacebody"> 72 </template><template autoinsert="true" context="enumbody_context" deleted="false" description="Code in new enum type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.enumbody" name="enumbody"> 73 </template><template autoinsert="true" context="annotationbody_context" deleted="false" description="Code in new annotation type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name="annotationbody"> 74 </template><template autoinsert="true" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock"> 75 // ${todo} Auto-generated catch block 76 ${exception_var}.printStackTrace(); 77 </template><template autoinsert="false" context="methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody"> 78 // ${todo} Auto-generated method stub 79 ${body_statement}</template><template autoinsert="true" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody"> 80 ${body_statement} 81 // ${todo} Auto-generated constructor stub 82 </template><template autoinsert="false" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody"> return ${field}; 83 </template><template autoinsert="false" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody"> ${field} = ${param}; 84 </template></templates>