代码之家  ›  专栏  ›  技术社区  ›  dcp

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

  •  6
  • dcp  · 技术社区  · 15 年前

    在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);
    }
    

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

    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;
        }
    
    }
    
    2 回复  |  直到 10 年前
        1
  •  5
  •   mtk    13 年前

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

    然后,在列表中选择“Comments/overriding methods”,并使用“Comments/methods”中的内容更改内容:

    /**
     * ${tags}
     */
    

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

        2
  •  0
  •   Jarek Rozanski    15 年前

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