开发者

Method linking/anchoring in Java

开发者 https://www.devze.com 2023-04-04 08:19 出处:网络
I created several Java methods that indirectly related. Question is, can I create some hyperlink between those methods as reference?

I created several Java methods that indirectly related. Question is, can I create some hyperlink between those methods as reference? I am usi开发者_Python百科ng Eclipse for Java IDE.


You can use the JavaDoc @see tag:

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

This generates a hyperlink in your JavaDoc.


In Eclipse, code completion also works in comments and can be used to create links. When you start typing the name of a class, hit Ctrl + Space to get a list of matching classes. It will create an @link tag for that class. Adding a # behind the name and repeating the autocompletion shortcut gives you a list of methods of that class. For methods of the same class you are working in, just type # and hit auto completion.

Clicking on a class or method name in the comment while holding Ctrl will let you jump to that class or method, even without the @see or @link tags.


I'd recommend the @see Javadoc tag; other than that (and the previously-mentioned, but IMO less semantically meaningful @link tag), not really.


As others pointed out, your question could stand some clarification. If you don't mean JavaDoc, but you mean somehow relate the classes together even though they have no common interface, you can use a marker interface, which is an interface with no methods. It's so called because it adds a marker to the classes, and you can test whether a class implements the interface.

0

精彩评论

暂无评论...
验证码 换一张
取 消