MyEclipse注释配置

MyEclipse注释配置

  1. 配置路径

1.1.      JAVA

      打开MyEclipse,选择Window>Preferences>Java>Code Style>Code Templates>Comments.

1.2.      JS

      打开MyEclipse,选择Window>Preferences>MyEclipse>Files and Editors>JavaScript> Code Style> Code Templates>Comments.

  1. 配置说明

2.1.      Files(类文件注释)

l  使用范围

      对class文件进行说明。

l  触发机制

      新建class文件时触发,增加在class文件最顶部。

l  配置内容

/*

 * @title: ${file_name}

 * @package:${package_name}

 * @description:${todo}

 * @author: Li_Zhenzhong@founder.com

 * @date: ${date} ${time}

 * @version:V1.0

 */

l  配置说明

title: 文件名称;

package:文件所在报名;

description:文件功能描述;

author:作者;

date:创建时间;

version:版本;

     

2.2.      Types(类注释)

l  使用范围

      对class类进行说明。

l  触发机制:

      在class类方法前使用:”/**“+回车。

l  配置内容:

/**

 * @className: ${type_name}

 * @description:${todo}

 * @author: Li_Zhenzhong@founder.com

 * @date: ${date} ${time}

 * ${tags}

 */

l  配置说明:

className: 类名称;

description:文件功能描述;

author:作者;

date:创建时间;

2.3.      Fields(变量注释)

l  使用范围

      对类中的变量进行注释。

l  触发机制:

l  配置内容:

/**

 * @fields ${field} ${field_type} :${todo}

 */

l  配置说明:

fields: 变量名称,类型:作用;

2.4.      Methods(方法注释)

l  使用范围

      对class类中的方法进行说明。

l  触发机制:

      在方法前使用:”/**“+回车。

l  配置内容:

/**

 * @title: ${enclosing_method}

 * @description:${todo}

 * @author: Li_Zhenzhong@founder.com

 * ${tags}

 * @date:${date}${time}

 */

l  配置说明:

title:方法名

description:文件功能描述;

author:作者;

* ${tags} ${return_type}:参数和返回值类型

date:创建时间;

throws:抛出哪些异常

2.5.      Overriding Methods(方法注释)

l  使用范围

      对class类中的方法进行重写的方法进行说明。

l  触发机制:

      在方法前使用:”@ Overriding“。

l  配置内容:

/**

 * @title: ${enclosing_method}

 * @description:${todo}

 * @author: Li_Zhenzhong@founder.com

 * ${tags}

 * @date:${date}${time}

 */

l  配置说明:

title:方法名

description:文件功能描述;

author:作者;

* ${tags} ${return_type}:参数和返回值类型

date:创建时间;

throws:抛出哪些异常

模版文件:

<?xml version="1.0" encoding="UTF-8"?>
<templates>

<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"> 
/**  
* 创建一个新的实例 ${enclosing_type}.  
*  
* ${tags}  
*/
</template>

<template autoinsert="true"
                 context="settercomment_context"
                 deleted="false"
                 description="Comment for setter method"
                 enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment"
                 name="settercomment">
/**  
* @param ${param} the ${bare_field_name} to set  
*/
</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">
/**  
 
* ${enclosing_method}(这里用一句话描述这个方法的作用)  
 
* TODO(这里描述这个方法适用条件 – 可选)  
 
* TODO(这里描述这个方法的执行流程 – 可选)  
 
* TODO(这里描述这个方法的使用方法 – 可选)  
 
* TODO(这里描述这个方法的注意事项 – 可选)  
 
* @param   name  
 
* @param  @return    设定文件  
 
* @return   DOM对象  
 
* @Exception 异常对象  
 
* @since  CodingExample Ver(编码范例查看) 1.1  
 
*/
</template>

<template autoinsert="true"
                 context="delegatecomment_context"
                 deleted="false"
                 description="Comment for delegate methods"
                 enabled="true"
                 id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
                 name="delegatecomment">
/**  
* ${tags}  
* ${see_to_target}  
*/
</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">
/**  
* fileName:${file_name}  
*  
* versionInfo:  
* date:${date}  
* Copyright @ Corporation ${year}   
*/
</template>

<template autoinsert="false"
                 context="gettercomment_context"
                 deleted="false"
                 description="Comment for getter method"
                 enabled="true"
                 id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
                 name="gettercomment">
/**  
* ${bare_field_name}  
*  
* @return  the ${bare_field_name}  
* @since   CodingExample Ver(编码范例查看) 1.0  
*/  
</template>

<template autoinsert="true"
                 context="overridecomment_context"
                 deleted="false"
                 description="Comment for overriding methods"
                 enabled="true"
                 id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
                 name="overridecomment">
/**
* (non-Javadoc)  
* ${see_to_overridden}  
*/
</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">
/**  
* ${field}:${todo}(用一句话描述这个变量表示什么)  
*  
* @since Ver 1.0  
*/  
</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">
/**  
*   
* projectName:${project_name}  
* typeName:${type_name}  
* classDescription:  
* author:yubo 
* createTime:${date} ${time}  
* modifiedName:  
* modifiedTime:${date} ${time}  
* remarks:  
* @version   
*   
*/</template>

</templates> <?xml version="1.0" encoding="UTF-8"?>
<templates>

<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"> 
/**  
* 创建一个新的实例 ${enclosing_type}.  
*  
* ${tags}  
*/
</template>

<template autoinsert="true"
                 context="settercomment_context"
                 deleted="false"
                 description="Comment for setter method"
                 enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment"
                 name="settercomment">
/**  
* @param ${param} the ${bare_field_name} to set  
*/
</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">
/**  
 
* ${enclosing_method}(这里用一句话描述这个方法的作用)  
 
* TODO(这里描述这个方法适用条件 – 可选)  
 
* TODO(这里描述这个方法的执行流程 – 可选)  
 
* TODO(这里描述这个方法的使用方法 – 可选)  
 
* TODO(这里描述这个方法的注意事项 – 可选)  
 
* @param   name  
 
* @param  @return    设定文件  
 
* @return   DOM对象  
 
* @Exception 异常对象  
 
* @since  CodingExample Ver(编码范例查看) 1.1  
 
*/
</template>

<template autoinsert="true"
                 context="delegatecomment_context"
                 deleted="false"
                 description="Comment for delegate methods"
                 enabled="true"
                 id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
                 name="delegatecomment">
/**  
* ${tags}  
* ${see_to_target}  
*/
</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">
/**  
* fileName:${file_name}  
*  
* versionInfo:  
* date:${date}  
* Copyright @ Corporation ${year}   
*/
</template>

<template autoinsert="false"
                 context="gettercomment_context"
                 deleted="false"
                 description="Comment for getter method"
                 enabled="true"
                 id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
                 name="gettercomment">
/**  
* ${bare_field_name}  
*  
* @return  the ${bare_field_name}  
* @since   CodingExample Ver(编码范例查看) 1.0  
*/  
</template>

<template autoinsert="true"
                 context="overridecomment_context"
                 deleted="false"
                 description="Comment for overriding methods"
                 enabled="true"
                 id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
                 name="overridecomment">
/**
* (non-Javadoc)  
* ${see_to_overridden}  
*/
</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">
/**  
* ${field}:${todo}(用一句话描述这个变量表示什么)  
*  
* @since Ver 1.0  
*/  
</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">
/**  
*   
* projectName:${project_name}  
* typeName:${type_name}  
* classDescription:  
* author:yubo 
* createTime:${date} ${time}  
* modifiedName:  
* modifiedTime:${date} ${time}  
* remarks:  
* @version   
*   
*/</template>

</templates> 

 附录:Eclipse针对java代码模板的内置变量
cursor 将编辑器的光标放在这个位置。 N/A
date 插入当前日期。
dollar 插入货币的文字符号。 $
elemType 尝试猜测具有给定 ID 的这个元素的类型。 MyType
enclosing_method 插入模板被插入其中的那个方法的名称。 method()
enclosing_method_arguments 为包围方法插入参数。 arg1, arg2
enclosing_package 插入当前类的包名。 com.example.ui
enclosing_project 插入包含所编辑的这个类的项目的名称。 myProject
enclosing_type 插入正在编辑的类型(类)的名称。 MyType
exception_variable_name 插入一个异常变量名称,进行最佳猜测。 e, ioe
file 文件的简称。 MyType.java
import 如果尚未导入,那么针对给定类型插入一个导入声明。 import com.example.ui.MyOtherType
importStatic 与 import 相同,只不过是静态导入。 import static com.example.ui.MyOtherType.*
line_selection 将选中的行插入到这里。这对用模板包装行是很有用的。 以选中行作为主体的 do、while 循环
primary_type_name 没有扩展名的文件简称。 MyType
time 插入当前的时间。
todo 注释中的 TODO 标记。 TODO
user 当前用户的名字。 ngood
var 解析为本地变量,如果不只一个,就提供一个列表。 myvar
word_selection 插入当前选中的单词。 N/A
year 将现在的年份插入到代码中。 2010

 
原文地址:https://www.cnblogs.com/Lightning-Kid/p/3873825.html