IDEA修改文档注释
设置IDEA创建Class时自动添加头部注释:
打开file->setting->Editor->File and Code Templates->Includes->File Header
/**
*@BelongsProject: ${PROJECT_NAME}
*@BelongsPackage: ${PACKAGE_NAME}
*@Author: ChenLan
*@Date: ${DATE} ${TIME}
*@Description: TODO
*/
@BelongsProject: ${PROJECT_NAME} //所属项目
@BelongsPackage: ${PACKAGE_NAME} //所属包
@Author: ChenLan //作者
@Date: ${DATE} ${TIME} //时间
@Description: TODO //描述
创建一个新的类:
设置快捷键添加方法注释:
打开file->setting->Editor->Live Templates
点击右边的加号,选择Template Group…
在弹框中设置名字
点击右边的加号,选择Live Template
设置模板:
/**
* @Author: ChenLan
* @Date: $date$ $time$
*/
其中:
@Author:----作者(这里使用了固定格式)
@Date: ----时间(年月日 时分)
注:方法的描述直接写到/**…*/注释中,在调用方法的地方,鼠标放在方法上,IDEA会弹出提示,显示方法描述信息。
点击下方Define,然后选择Everywhere
然后点击右边的Edit variables
点击右边的上下箭头将date和time调整到上边,否则使用时会出现空格
params参数值:
groovyScript("def result='\\n'; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(i == 0 && params[i] == ''){return '';};result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : ' ')}; return result", methodParameters())
保存。使用快捷键,我这里设置的是在方法块内输入add然后按Tab键
常用的预设的变量,这里直接贴出官网给的:
${PACKAGE_NAME} - the name of the target package where the new class or interface will be created.
${PROJECT_NAME} - the name of the current project.
${FILE_NAME} - the name of the PHP file that will be created.
${NAME} - the name of the new file which you specify in the New File dialog box during the file creation.
${USER} - the login name of the current user.
${DATE} - the current system date.
${TIME} - the current system time.
${YEAR} - the current year.
${MONTH} - the current month.
${DAY} - the current day of the month.
${HOUR} - the current hour.
${MINUTE} - the current minute.
${PRODUCT_NAME} - the name of the IDE in which the file will be created.
${MONTH_NAME_SHORT} - the first 3 letters of the month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL} - full name of a month. Example: January, February, etc.