-IDEA specification code comments configure Java class methods comment template

Transfer: https: //www.cnblogs.com/niaonao/p/12190602.html

When team development, business module allocation, clearer and more complete management code comments, the better the back maintenance, management back then also a lot of convenience. There is also plays a role in the "text blocks", you know. Note need not be detailed functional blocks of code blocks method outlined on the line. Otherwise, we should look back in March after the curse, Ma Wan found himself wrote, tut tut ...

Three common way of Java annotations

// 声明常量
int number;
/*
 * 类主函数
 */
public static void main(String[] args) {
}
    /**
     * @param masterId  品牌商Id
     * @param shopId    店铺Id
     * @param skuId     商品skuId
     * @description: 校验商品标识码与店铺的所属关系
     * @return: net.jdcloud.APIECRM.model.ValidateSkuUsingGETResponse
     * @author: niaonao
     * @date: 2020/01/13
     */
    public static ValidateSkuUsingGETResponse validateSkuUsing(String masterId, String shopId, String skuId){
        return null;
    }

Custom comments template

Class Notes templates

Menu path File-Settings-Editor-File under Templates add comments and Code Templates-Incudes-File Header, click Apply OK After you configure the template application.

Custom comments template

/**
 * @className: ${NAME}
 * @description: TODO 类描述 
 * @author: niaonao
 * @date:  ${DATE}
 **/
/**
 * @className: CrowdService
 * @description: 人群对象业务
 * @author: niaonao
 * @date: 2020/1/13
 **/
public interface CrowdService {
}

Custom comments template is not fully variable reference table

Methods Note Templates

Adding a new set of templates under the menu path File-Settings-Editor-Live Templates, name the custom JavaTemplateGroup. Select the template group, click the Add button on the right side, create a new template.

Abbreviation configured *.
Description custom description.
Template Text Custom Templates

*
 $param$
 * @description: TODO
 * @return: $return$
 * @author: niaonao
 * @date: $date$
 */

Edit variables Editing variables

Variable return expression is methodReturnType ()
variable date expression for the date ()
variable expression is param

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())

If a warning message No Applicable contexts, click Define Java can be selected.

Here Expend With configured for the Enter key, generated comments shortcuts, see personal habits, but also the Tab key can.

Click Apply OK to apply the configuration. Results are as follows

    /**
     * @param: masterId
     * @param: shopId
     * @param: skuId
     * @description: TODO
     * @return: net.jdcloud.APIECRM.model.ValidateSkuUsingGETResponse
     * @author: niaonao
     * @date: 2020/1/13
     */
    public static ValidateSkuUsingGETResponse validateSkuUsing(String masterId, String shopId, String skuId) {
        return null;
    }

Methods annotated template is not available in and outside the method, if used outside the method to get less than @param, annotate @param null;

类注释模板在文件创建时生成,已创建文件不会触发该模板,会触发方法注释模板。

Guess you like

Origin www.cnblogs.com/wbyixx/p/12190769.html