Phil
Phil

Reputation: 36289

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

More specifically, can it generate a commend that is simply the name of the method? For example, for the main method:

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

Upvotes: 1

Views: 758

Answers (2)

ring bearer
ring bearer

Reputation: 20783

If you are looking to add this to every method ( hand written & generated) you will have to use some code formatting tool like Jalopy

There is a nice eclipse plugin for Jalopy by which you can apply your formatting rules on current file or across packages.

See this incarnation of Jalopy has exactly what you are looking for.

Upvotes: 2

quaylar
quaylar

Reputation: 2635

For generated methods only (will not work on existing ones): Preferences - Java - Templates:

Find the templates for method generation and edit them to your needs (insert comments after the closing bracket using the name-variable).

Example:

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

Upvotes: 2

Related Questions