簡體   English   中英

Eclipse可以在方法末尾自動生成Java注釋嗎?

[英]Can Eclipse auto-generate Java comments at the end of a method?

更具體地說,它是否可以產生僅是方法名稱的推薦? 例如,對於main方法:

public static void main(String[] args) {
    System.out.println("ping");
}//main  <--This comment, that has the name of the method

僅對於生成的方法(不適用於現有方法):首選項-Java-模板:

查找用於生成方法的模板,然后根據需要進行編輯(使用名稱變量在右括號后插入注釋)。

例:

private ${return_type} ${name}(${}) {
    ${cursor}
}// ${name}

如果您希望將其添加到每個方法(手寫和生成的)中,則必須使用一些代碼格式化工具,例如Jalopy

Jalopy有一個不錯的eclipse插件,您可以通過它將格式化規則應用於當前文件或跨包。

看到Jalopy的化身正是您想要的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM