一、類文件注釋
主要路徑File | Settings | Editor | File and Code Templates
1、首先點擊右上角的file
2、點擊進入settings
3、選擇 Editor—> File and Code Templates—>includes—>FileHeader
4、在里面定義你自己想要的簽名,
(注)${DATE} 里面的一定要大寫才能獲得時間
這是我定義的可以參考
/** * * @description * @version 1.0 * @author rongrong * @date ${DATE} ${TIME} * */
5、去掉名字下面的波浪線
把鼠標放到波浪線上會提示 Spellchecker inspection helps locate typos and misspelling in your code, comments and literals, and fix them in one click
翻譯過來就是:拼寫檢查器檢查可以幫助查找拼寫錯誤和拼寫錯誤在您的代碼、 注釋和文本、 並修復它們中一次點擊。
其實就是idea有單詞自動檢查的功能,而你這個名字又不是一個單詞,所有給個波浪線提示你,我們要做的就是把它加到詞典里邊去,讓idea知道我已經把它當成一個單詞了,不要在提示了。
右鍵點擊該單詞–>spelling–>save ‘name’ to project-level distionary
二、方法注釋
1、打開file->setting->Editor->LiveTemplates點擊右邊上面那個綠色的+號,選擇Template Group雙擊,然后彈出一個窗口,隨便添加一個名字,我這里添加的是ydgroup然后點擊OK
2、選擇剛創建的group再次點擊右邊的加號,然后選擇LiveTemplates,點擊define之后你可以選擇應用的位置,可以選擇everywhere
如果想為你的注釋指定一些變量,可以利用whatwhatwhat 然后選擇 Edit variables (注意只有當變量被$$包圍是 右側的Edit variables才可以點擊)在里面選擇idea提供的參數表達式 方法參數可以選擇methodParameters() 返回值類型 methodReturnType()
注:當注釋放在函數的外面時,自動獲取的參數都為空
原文鏈接:https://blog.csdn.net/qq_39098813/article/details/80731698