Why doesn't / ** [new line] always insert a Javadoc template, including @param and @return in Eclipse?

I document the code in Eclipse and use / ** and then enter a lot to insert the Javadoc template. However, this does not always work for some reason, it will create a template for writing comments, but it will not automatically insert @param and @return text. If I copy the same method to another class, it will introduce the full template.

It would be a great help if someone could tell me why this would not be done in some situations.

+7
java eclipse javadoc
source share
3 answers

As far as I know, this usually happens when Eclipse does not know exactly which method you want to document.

A more reliable way would be to select a method / class, etc. you want to create a JavaDoc for and press ALT + SHIFT + J or right-click on a method in the class path and click Source β†’ Generate comment.

+7
source share

This always works for me IF there is a comment above the method I'm trying to add for documentation. Here is an example of some code and an undocumented method in which it will not work:

public class Test { // Declare some fields. Bla bla bla. // ~ Constructors public Test() { // <-- If I insert /** above this line it fails to work } } 

My fix usually temporarily declares a variable that separates my method from comments, so Eclipse will recognize what I'm doing ...

 public class Test { // Declare some fields. Bla bla bla. // ~ Constructors int i; public Test() { // <-- If I insert /** above this line it works. Then discard the temp var. } } 
+1
source share

This happened to me sometimes with the last line, Mars. Restarting Eclipse fixes this. It seems I really need to restart Eclipse every day to avoid random problems like this.

0
source share

All Articles