如何修复不再自动填充/自动完成的Javadoc?

如何修复不再自动填充/自动完成的Javadoc?,java,eclipse,autocomplete,javadoc,workspace,Java,Eclipse,Autocomplete,Javadoc,Workspace,当您在Eclipse中键入/**并在上面输入一个方法时,它将生成Javadoc,例如: /** * Finds a World using a String, greets the World, * and then returns a reference to the World. * * @param world - the World to find and greet. * @return the reference to the World. * @throws Apoc

当您在Eclipse中键入/**并在上面输入一个方法时,它将生成Javadoc,例如:

/**
 * Finds a World using a String, greets the World,
 * and then returns a reference to the World.
 * 
 * @param world - the World to find and greet.
 * @return the reference to the World.
 * @throws ApocalypseException - if the World is not found.
 */
public World helloWorld(String world) throws ApocalypseException {
    ...
}
但是,有时当我向方法添加Javadoc时,它会随机停止生成:

/**
 * 
 */
public Universe helloUniverse(String universe) throws BigBangException {
    ...
}

这不是特定于类的。我将在一个类中生成5个左右的方法,然后它将停止生成。我假设Workspace无法读取我的类文件,所以我删除了它们并重新编译,但这并没有解决问题。我也尝试过重新启动Eclipse,但也没有成功。

不知道具体细节,但是如果您尝试创建一个它无法完全理解的方法(例如,将尚未导入的类作为返回值),您将得到第二个结果,而不是所需的结果


无论哪种方式,您都可以通过突出显示方法名称并使用“Source”->“Generate Element comment”(从上下文菜单或窗口菜单栏)来强制生成javadoc注释。或者是它的热键,不管它在eclipse prefs中分配给什么。

为了解决这个问题,我将所有没有生成Javadoc的方法剪切到一个具有类似导入的类中,然后在另一个类中生成Javadoc注释,并正确生成。然后我将它们切回到原始类中,没有任何错误


这可能是Eclipse中的一个错误,因为它经常发生在我身上。

如果我尝试以这种方式生成注释,它会使用非Javadoc注释:
/*(非Javadoc)*@see java.lang.Object#toString()*/
您的第一个建议是正确的。添加具有新返回值的新方法确实在类的底部生成了正确的Javadoc。但是,应用相同的逻辑并从类中删除所有导入以强制错误并没有改变Javadoc注释的生成方式。您显示的“非Javadoc”注释是重写方法上注释的默认行为。您可以在Prefs->Java->Code Style->Code Templates中通过Comments->Overriding methods项进行更改。我不太明白-您正在删除所有导入,并且javadoc注释正在自动生成?如果是这样,那就是成功。如回答中所述,如果没有,这是意料之中的。对我来说,你可能需要检查你的类中的错误,通过(默认)在内容上的红色扭曲线覆盖,或者在标记视图中(一旦文件被保存)。在我的类中没有错误,甚至没有警告。正如我在问题中所说,它根本不会生成Javadoc注释。