Add Document Comment Shortcuts in Eclipse

E.g:

/**
  * @param  
  * @return

  */

The shortcut keys are: ALT + SHIFT + J

Want to change to other shortcut keys:

Window-->Preferences-->General-->Keys; Find "add javadoc comment" to change your favorite shortcut keys.

In addition, if you feel that the annotation is not comfortable, you can also change it. There are two ways to modify it:

1. Modify directly under the template given by eclipse

2. Write an xml document yourself and import it

So let's talk about the first method first:

open eclipse

Window-->Preferences-->Java-->Code Style --> Code Templates --> Comments --> types --> Edit

/**   
*    
* Project name: ${project_name}   
* Class name: ${type_name}   
* Class description:   
* Created by: ${user}   
* Created by: ${date} ${time}   
* Modified by: ${ user}   
* Modification time: ${date} ${time}   
* Modification note:   
* @version    
*    
*/

The second method is:

Click the import button on the right to select the template .xml file you wrote

The following is a comment line template codetemplates.xml, which can be imported and used directly. Post the source code for your reference

<?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} (here describes the function of this method in one sentence)
* TODO (here describes the applicable conditions of this method - optional)
* TODO (here describes the execution flow of this method - optional )
* TODO (the usage of this method is described here - optional)
* TODO (the notes about this method are described here - optional)
* @param name
* @param @return setting file
* @return String DOM object
* @Exception Exception object
* @since CodingExample Ver (coding example view) 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">
/**
* 文件名:${file_name}
*
* 版本信息:
* 日期:${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} (describe what this variable represents in one sentence)
*
* @since Ver 1.1
*/
</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">
/**
*
* Project name: ${project_name}
* Class name: ${type_name}
* Class description:
* Created by: ${user}
* Created by: ${date} ${time}
* Modified by : ${user}
* Modification time: ${date} ${time}
* Modification note:
* @version
*
*/</template>

</templates>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325852203&siteId=291194637