Eclipse工具使用格式化模板应用

在编写完代码后使用代码格式化程序对代码进行格式化,有利于版本冲突时进行对比和文件合并。想到当前代码编写格式多少有些太个性化,如果可以创建一份代码模板,将之导入到所有人的工具中,然后所有的代码在编写后都进行格式化,则避免了代码格式太混乱的情况,有利于大家阅读代码。

Comments
Files

/**
 * Copyright (C) aumy2008, ${year}
 */

Getters

/**
 * @return Returns the ${bare_field_name}.
 */

Setters

/**
 * @param ${param} The ${bare_field_name} to set.
 */

Constructors

/**
 * ${tags}
 */

Types

/**
 *
 * @author aumy2008([email protected]) in ${date}
 * @since 1.0
 *
 * ${tags}
 */

Fields

/**
 *
 */

Methods

/**
 * ${tags}
 * @since 1.0
 */

Overriding methods

/* (non-Javadoc)
 * ${see_to_overridden}
 */

2.代码
New Java files

/**
 * Copyright (C) aumy2008, ${year}
 */
${package_declaration}
/**
 *
 * @author aumy2008([email protected]) in ${date}
 * @since 1.0
 */
${typecomment}
${type_declaration}

Catch block body

// ${todo} Auto-generated catch block
${exception_var}.printStackTrace();

Method budy

// ${todo} Auto-generated method stub
${body_statement}

Constructor body

${body_statement}
// ${todo} Auto-generated constructor stub

Getter body

return ${field};

Setter body

${field} = ${param};

【编辑推荐】

  1. Eclipse or Netbeans
  2. eclipse中编码设置
  3. Eclipse用户中使用Linux的数量赶超Windows
  4. Eclipse中代码模版
  5. 谈在Eclipse中配置tomcat
THE END