java - Viewing links in source code comments

Hi,   
When ever I open an open source project or java's own jar's code (intellij)   
and comments I see something like the follows:

(e.g. mockito source )


    /**  
     * Use <code>doReturn()</code> in those rare occasions when you cannot use {@link Mockito#when(Object)}.
     * <p>
     * <b>Beware that {@link Mockito#when(Object)} is always recommended for stubbing because it is argument type-safe
     * and more readable</b> (especially when stubbing consecutive calls).
     * <p>
     * Here are those rare occasions when doReturn() comes handy:
     * <p>
       ....
       ....
       ....
     * See examples in javadoc for {@link Mockito} class
     *
     * @param toBeReturned to be returned when the stubbed method is called
     * @return stubber - to select a method for stubbing
     */
     public static Stubber doReturn(Object toBeReturned) {


I am guessing the parts using @ in the comments can be viewed as links
Is it ?   
How do I view them as links?

Thanks.

0
2 comments

You can link through to {@link} javadoc annotations, but not {@code} ones. To click through to a {@link} annotation, just hover over it and do either Ctrl+Click or Ctrl+B (or with your cursor on the value use the menu Navigate > Declaration). Of course, the source has to be attached for this to work.

Another option, if you want to see the formatted documentation, is to put your cursor on the {@link} value and use the quick documentation (Ctrl+Q) shortcut to view the doc. An advantage of this is that either the source or the javadoc can be attached for this to work. So for some libraries if you only have access to the javadoc and not the source, this can be useful.

Note that for all of these, IDEA will break the link up into parts. For example, if the entry is {@link String#trim()}, if my cursor is on the "String", I will be taken to or see the documentation for the String class. If my cursor is over the "trim()", I will be taken to or view the source for the trim() method.


p.s. all of these work for code itself... not just for references in documentations.

0

Be aware that IntellJ does not seem to support linking to a file, with either @link or @see. The auto-complete NEVER brings up the directory structure and if you type it out manually, IntellJ highlights it to indicate it can't find it. Curiously, if you use something like {@link src/foo/bar}, the src will NOT be highlighted, yet you are still unable to Go To Declaration on it, as IntelliJ can't find it.

AFAIK, this is supposed to be supported by the JSDoc spec.

0

Please sign in to leave a comment.