设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元素啦。现就每一个元素逐一介绍:
文件(Files)注释标签:
/**
* @Title: ${file_name}
* @Package ${package_name}
* @Description: ${todo}(用一句话描述该文件做什么)
* @author A18ccms A18ccms_gmail_com
* @date ${date} ${time}
* @version V1.0
*/
类型(Types)注释标签(类的注释):
/**
* @ClassName: ${type_name}
* @Description: ${todo}(这里用一句话描述这个类的作用)
* @author A18ccms a18ccms_gmail_com
* @date ${date} ${time}
*
* ${tags}
*/
字段(Fields)注释标签:
/**
* @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)
*/
构造函数标签:
/**
* <p>Title: </p>
* <p>Description: </p>
* ${tags}
*/
方法(Constructor & Methods)标签:
/**
* @Title: ${enclosing_method}
* @Description: ${todo}(这里用一句话描述这个方法的作用)
* @param ${tags} 设定文件
* @return ${return_type} 返回类型
* @throws
*/
覆盖方法(Overriding Methods)标签:
/* (非 Javadoc)
* <p>Title: ${enclosing_method}</p>
* <p>Description: </p>
* ${tags}
* ${see_to_overridden}
*/
代表方法(Delegate Methods)标签:
/**
* ${tags}
* ${see_to_target}
*/
getter方法标签:
/**
* @return ${bare_field_name}
*/
setter方法标签:
/**
* @param ${param} 要设置的 ${bare_field_name}
*/
I’ll give you a few of the General Template Variables you can use:
${cursor} Specifies the cursor position when the template edit mode is left. This is useful when the cursor should jump to another place than to the end of the template on leaving template edit mode.
${date} Evaluates to the current date.
${dollar} Evaluates to the dollar symbol ‘$’. Alternatively, two dollars can be used: ‘$$’.
${enclosing_method} Evaluates to the name of the enclosing name.
${enclosing_method_arguments} Evaluates to a comma separated list of argument names of the enclosing method. This variable can be useful when generating log statements for many methods.
${enclosing_package} Evaluates to the name of the enclosing package.
${enclosing_project} Evaluates to the name of the enclosing project.
${enclosing_type} Evaluates to the name of the enclosing type.
${file} Evaluates to the name of the file.
${line_selection} Evaluates to content of all currently selected lines.
${primary_type_name} Evaluates to the name primary type of the current compilation unit.
${return_type} Evaluates to the return type of the enclosing method.
${time} Evaluates to the current time.
${user} Evaluates to the user name.
${word_selection} Evaluates to the content of the current text selection.
${year} Evaluates to the current year.
Java Specific Template Variables:
${id:field(type)} Evaluates to a field in the current scope that is a subtype of the given type. If no type is specified, any non-primitive field matches. Example: ${count:field(int)}
${id:var(type)} Evaluates to a field, local variable or parameter visible in the current scope that is a subtype of the given type. If no type is specified, any non-primitive variable matches. Example: ${array:var(java.lang.Object[])}
${id:localVar(type)} Evaluates to a local variable or parameter visible in the current scope that is a subtype of the given type. If no type is specified, any non-primitive local variable matches.
${array} is a shortcut for ${array:localVar(java.lang.Object[])}, but also matches arrays of primitive types.
${collection} is a shortcut for ${collection:localVar(java.util.Collection)}.
${iterable} is a shortcut for ${iterable:localVar(java.lang.Iterable)}, but also matches arrays.
${id:argType(variable, n)} Evaluates to the nth type argument of the referenced template variable. The reference should be the name of another template variable. Resolves to java.lang.Object if the referenced variable cannot be found or is not a parameterized type. Example: ${type:argType(vector, 0)} ${first:name(type)} = ${vector:var(java.util.Vector)}.get(0)
${id:elemType(variable)} Evaluates to the element type of the referenced template variable. The reference should be the name of another template variable that resolves to an array or an instance of java.lang.Iterable. The elemType variable type is similar to ${id:argType(reference,0)}, the difference being that it also resolves the element type of an array.
${array_type} is a shortcut for ${array_type:elemType(array)}.
${iterable_type} is a shortcut for ${iterable_type:elemType(iterable)}.
${id:newName(reference)} Evaluates to an non-conflicting name for a new local variable of the type specified by the reference. The reference may either be a Java type name or the name of another template variable. The generated name respects the code style settings. ${index} is a shortcut for ${index:newName(int)}.
${iterator} is a shortcut for ${iterator:newName(java.util.Iterator)}.
${array_element} is a shortcut for ${array_element:newName(array)}.
${iterable_element} is a shortcut for ${iterable_element:newName(iterable)}.
${array} Evaluates to a proposal for an array visible in the current scope.
${array_element} Evaluates to a name for a new local variable for an element of the ${array} variable match.
${array_type} Evaluates to the element type of the ${array} variable match.
${collection} Evaluates to a proposal for a collection visible in the current scope.
${index} Evaluates to a proposal for an undeclared array index.
${iterator} Evaluates to an unused name for a new local variable of type java.util.Iterator.
${iterable} Evaluates to a proposal for an iterable or array visible in the current scope.
${iterable_element} Evaluates to a name for a new local variable for an element of the ${iterable} variable match.
${iterable_type} Evaluates to the element type of the ${iterable} variable match.
${todo} Evaluates to a proposal for the currently specified default task tag.
分享到:
相关推荐
eclipse-codetemplate.xml
<template autoinsert="true" context="classcomment" deleted="false" description="Class comment" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classcomm" name="cc"> /** * ${todo} ${...
"code-template.zip" 文件提供了一种高效解决方案,即畅购商城中的代码生成器,它使得开发者能够快速生成基于数据库的增删改查操作代码,极大地简化了开发流程。下面,我们将深入探讨这个代码生成器的核心特点和使用...
标题 "codeTemplate" 暗示我们关注的是代码模板,这是一种在编程中提高效率的工具。在编程领域,代码模板允许开发者快速输入预定义的代码片段,尤其在编写重复性结构或者遵循特定规范的代码时非常有用。这些模板可以...
例如,`<template>`标签表示一个模板,`name`属性用于指定模板的名称,`context`属性定义了模板适用的上下文(如"JAVA_METHOD"表示方法内),而`description`属性则是对模板的描述。`code`标签内的内容就是实际要...
code template 模板
"startuml PHP 5 Code Generator Template" 是一个专门针对PHP 5编程语言设计的代码生成模板,其核心功能是自动生成PHP 5类的结构。在这个项目中,我们可以探讨以下几个关键知识点: 1. **StartUML**: StartUML 是...
eclipse 标准 codetemplates.xml 代码模板,标准、简洁、好用
codetemplates.xml下载(Eclipse 注释代码模板文件)
标题中的“acm template code”指的是ACM(国际大学生程序设计竞赛)的代码模板集合,这类模板通常包含各种算法和数据结构的实现,用于帮助参赛者快速解决竞赛中遇到的问题。ACM比赛强调高效编程和算法理解,因此,...
本文将详细介绍如何在Eclipse中设置Code Templates,以实现代码的自动格式化和一致性。 编码规范是软件开发中的一个重要环节,它有助于提高代码的可读性、可维护性和团队协作效率。在Eclipse中,通过设置Code ...
codeTemplates.xml,因为项目的需要,发现需要自己编写一个模板,从网上下载的感觉不太适合自己,于是就自己总结拼凑了一个,当然,你也可以下载之后根据你的需求再处理一下,有需要的拿走,不谢
压缩包内的两个文件“eclipse-codestyle.xml”和“eclipse-codetemplate.xml”分别对应Eclipse的代码风格配置和代码模板配置。 “eclipse-codestyle.xml”文件包含了编码规则,如缩进大小、行宽、命名规范等。在STS...
Eclipse作为一款强大的Java集成开发环境(IDE),提供了许多工具来帮助开发者保持代码整洁和规范,其中codeFormatter和codeTemplates是两个非常重要的功能。 codeFormatter是Eclipse内置的一种代码格式化工具,它...
windows-》preference—》java-》code style-》code template,点击import按钮。 导入成功后,点击comments选项,可以查看各个不同位置的注释,比如文件注释、变量注释、函数注释等。展示样式在Pattern下面的文本框...
java注释模版,使程序运行更让人容易看懂,和理解,加快速度
在编程世界中,代码格式模板(Code Format Template)是至关重要的,它定义了一种统一的代码风格,确保团队成员之间的代码可读性和一致性。华为作为全球知名的科技公司,对代码质量有着高标准的要求。"code format ...
从工作开始,经历了几个项目的开发,现在的项目一般都是一个团队共同开发,而每个人都有...主要包括三个方面:设置Code Templates、Eclipse formatter、Checkstyle,本篇主要介绍如何设置Code Templates,具体步骤如下