Writing a comment in Eclipse binding a specific string

I work with Eclipse in Java and with long long classes I need this function: in the top comment of the method (for example) there is a list of operations performed by the method. For each given operation, I would like to β€œhyperlink” part of the comment to a specific line of related code.

Then, using Ctrl + Click for this line, I can go directly to the specified line code.

Is such an action possible?

thanks

+8
java code-formatting eclipse eclipse-plugin
source share
3 answers

In the comment below your question, you say:

How can I bind methods?

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

 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 , class name and method (after manually entering # ).

Is this what you are looking for?

+6
source share

You can use the JavaDoc @see tag:

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

This creates a hyperlink in your JavaDoc.

SRC: method-linking-anchoring-in-java

+1
source share

The Eclipse IDE allows you to move from a method call to a method definition ("F3", I think).

Also, I don’t think there is a way to set up β€œspecial” navigation. Keep in mind if you need something like this, this is strong evidence that your methods are too great. Restore them.


A thought outside the window, if you were to feed your code with a beautiful printer with html code, you could embed HTML hyperlinks and HTML anchors in comments (javadoc or normal). A little luck, they will be available for viewing when viewing the HTML source code in a web browser.


Of course, Eclipse can follow javadoc "links". Obviously, standard tags cannot refer to depth inside a method, but I think you could write an Eclipse plugin that supports non-standard javadoc tags for binding to inline anchors and their navigation.

0
source share

All Articles