1. Set the class, interface, and enumeration head comment templates
ctrl + shift + s -> Editor->File and Code Templates
Set Class, Interface, Enum separately
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
* 〈功能概述〉<br>
* @className: ${NAME}
* @package: ${PACKAGE_NAME}
* @author: ${USER}
* @date: ${DATE} ${TIME}
*/
public class ${NAME} {
}
2. Set method annotation template
The method comment template is set according to the company's regulations or personal habits. There is no need to completely copy other people's things. The one that suits you is the best.
ctrl + shift + s -> LiveTemplates
2.1 Add template group
2.2 Add template
2.3 Template Naming
2.4 Define template format
*
* 概述
*
* @author yourName
* @date $date$ $time$
$params$
* @return $return$
*/
2.5 Select application scenarios
2.7 Select shortcut keys
2.6 Edit Template Parameters
date date()
time time()
params 参考下文
return methodReturnType()
It should be noted that a method may have multiple parameters. If it is set to @param, it will be tasteless. I set it to $params$ here, and the default parameter is set to
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n':'')}; return result", methodParameters())
3. Set the cursor to hover to display the content of the method comment