Javadoc for local variables?

前端 未结 6 1327
名媛妹妹
名媛妹妹 2021-01-17 09:33

Short question: Is it possible to create Javadoc for local variables? (I just want an explanation for my local variable when hovering over it in Eclipse) Thanks for any hint

6条回答
  •  萌比男神i
    2021-01-17 10:20

    It can be done using Annotations.

    Create a simple annotation type such as the following:

    @Retention(RetentionPolicy.SOURCE)
    @Target(ElementType.LOCAL_VARIABLE)
    @interface LocalVariableDocumentation {
        String value();
    }
    

    And use it on your local variable:

    @LocalVariableDocumentation("A very important object!")
    Object anImportantObject;
    

    Eclipse will show the annotation in the tooltip.

提交回复
热议问题