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.
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值