2017-08-01 79 views
1

在Eclipse中,当将javadoc注释块添加到其接口位于同一项目中的实现类(某个接口)的方法中时,可以键入/ *(斜线后跟一个星号),然后按Enter键并立即在该方法的顶部生成一个非javadoc注释,该注释引用该类使用@see注释实现的接口的javadoc。我如何在Intellij IDEA中实现这种行为?Intellij IDEA如何自动生成非javadoc注释块?

+0

看起来像https://youtrack.jetbrains.com/issue/IDEABKL-4761。 – CrazyCoder

+0

@CrazyCoder这是否意味着该功能在2005年首次被请求并且尚未实施? –

+0

是的,这是正确的。 – CrazyCoder

回答

2

你必须写/**,然后按ENTER 关键

对于全面实施:

添加下面的代码的接口方法上面。 @link等于@see

/** 
     * {@inheritDoc} 
     * This printHello method is .......... you write explanation here 
     * {@link com.example.uddhav.memoryuse.MyInterface} 
* I provided absolute reference of MyInterface here 
     */ 
     public void printHello(String str); /* your method */ 

在你的类,它实现接口,你就右键单击>生成>替代方法>勾选 “副本的javadoc”

接口

public interface MyInterface { 
    /** 
    * {@inheritDoc} 
    * {@link com.example.uddhav.memoryuse.MyInterface} 
    * This printHello method is .......... 
    */ 
    public void printHello(String str); 

    /** 
    * {@inheritDoc} 
    * This printUddhav method is .......... 
    */ 

    public void printUddhav(String strr); 

    public void printGautam(String strr); 

} 

public class MainActivity extends AppCompatActivity implements MyInterface{ 
/* right click > generate > override methods > copy JavaDoc */ 
/* you are done */ 

/* I generated these below */ 

/** 
    * {@inheritDoc} 
    * {@link MyInterface} 
    * This printHello method is .......... 
    * 
    * @param str 
    */ 
    @Override 
    public void printHello(String str) { 

    } 

    /** 
    * {@inheritDoc} 
    * This printUddhav method is .......... 
    * 
    * @param strr 
    */ 
    @Override 
    public void printUddhav(String strr) { 

    } 

    @Override 
    public void printGautam(String strr) { 

    } 

点击MyInterface的,你会被重定向到该接口上的方法。