0

当您在 Eclipse 中的方法上方键入 /** 并 Enter 时,它将生成 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,但也没有用。

4

2 回答 2

0

不知道您的具体情况,但是如果您尝试创建一个它无法弄清楚的方法(例如,将一个尚未导入的类作为返回值),您将获得第二个结果而不是期望一。

无论哪种方式,您都可以尝试通过突出显示方法名称并使用“Source”->“Generate Element Comment”(从上下文菜单或窗口菜单栏)来强制生成 javadoc 注释。或者为此的热键,无论它在你的 Eclipse 首选项中分配什么。

于 2012-11-05T20:08:50.263 回答
0

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

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

于 2012-11-17T04:28:40.803 回答