Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a comment in Eclipse linking a specific line

i'm working with Eclipse in Java and with long long classes i need a feature like this: in the top comment of a method (for example) there is a list of operations executed by the method. For each operation listed, i'd like to "hyperlink" a portion of the comment to a specific line of the related code.

Then using Ctrl+Click to that line i can jump directly to the specified line code.

Is it possible an operation like this?

Thanks

like image 318
Deviling Master Avatar asked Feb 21 '13 11:02

Deviling Master


2 Answers

You can use the JavaDoc @see tag:

/**
* @see MyClass#myMethod()
*/

This generates a hyperlink in your JavaDoc.

SRC: method-linking-anchoring-in-java

like image 167
Sabarish Avatar answered Oct 16 '22 13:10

Sabarish


In the comment below your question you say:

how can i link methods?

Take a look at the following example: you can press ctrl + click on bar() within the JavaDoc of foo() and eclipse jumps to the method bar().

public class Example {

    /**
     * JavaDoc of foo(). This method executes {@link Example#bar()}
     */
    public void foo() {
        bar();
    }

    /**
     * Javadoc of bar().
     */
    public void bar() { }
}

Eclipse even offers autocomplete for @link, the classname and the method (after you manually entered the #).

Is that what you are looking for?

like image 37
jlordo Avatar answered Oct 16 '22 13:10

jlordo