Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
eclipse添加未实现的方法,包括javadoc_Java_Eclipse_Code Generation - Fatal编程技术网

eclipse添加未实现的方法,包括javadoc

eclipse添加未实现的方法,包括javadoc,java,eclipse,code-generation,Java,Eclipse,Code Generation,在eclipse中实现接口时,它有一个非常好的特性,允许您“添加未实现的方法”,并且它将为接口方法生成方法存根 但是,它没有从接口方法中带来方法文档,我想知道是否有办法让eclipse做到这一点 这就是我想要发生的事情。假设我有这样一个界面: public interface BaseInterface { /** * This method takes the given string parameter and returns its integer value.

在eclipse中实现接口时,它有一个非常好的特性,允许您“添加未实现的方法”,并且它将为接口方法生成方法存根

但是,它没有从接口方法中带来方法文档,我想知道是否有办法让eclipse做到这一点

这就是我想要发生的事情。假设我有这样一个界面:

public interface BaseInterface {

    /**
     * This method takes the given string parameter and returns its integer value.
     * 
     * @param x the string to convert
     * @return the integer value of the string
     * 
     * @throws Exception if some error occurs
     */
    int method1(String x);
}
public class MyClass implements BaseInterface {

    /**
     * This method takes the given string parameter and returns its integer value.
     * 
     * @param x the string to convert
     * @return the integer value of the string
     * 
     * @throws Exception if some error occurs
     */
    public int method1(String x) {
        return 0;
    }

}
现在我创建了一个名为MyClass的类,它实现了这个接口。我希望发生的是,当我说“添加未实现的方法”时,我希望我的代码如下所示:

public interface BaseInterface {

    /**
     * This method takes the given string parameter and returns its integer value.
     * 
     * @param x the string to convert
     * @return the integer value of the string
     * 
     * @throws Exception if some error occurs
     */
    int method1(String x);
}
public class MyClass implements BaseInterface {

    /**
     * This method takes the given string parameter and returns its integer value.
     * 
     * @param x the string to convert
     * @return the integer value of the string
     * 
     * @throws Exception if some error occurs
     */
    public int method1(String x) {
        return 0;
    }

}

您可以通过JavaDoc注释来实现它。它不是特定于Eclipse的,可以在所有构建/文档生成工具中使用:

/**
 * My custom decumentation, and then the original one:
 * 
 * {@inheritDoc}
 */

是的:这些方法是使用您编写的代码模板生成的

您必须进入“窗口/首选项->Java/代码样式/代码模板”

然后,在列表中选择“注释/重写方法”,并使用“注释/方法”中的内容更改内容:


您甚至可以考虑添加一个
${see_to_overrided}
来直接链接到原始方法。但是,请注意,没有javadoc的方法将自动从其重写的方法继承其javadoc,因此这样的模板可能会生成比默认行为更不相关的文档。

我尝试过,但没有成功。它没有为该方法生成任何文档。