50

I would like to link a method of another object using @see from a comment block
@see is only giving me the option to link classes, not methods.

What is the hack?

public class A {
  B bee;

  /**
   * Just invoking methodB on bee.
   * @see B.methodB() <-- There
   */
  public methodA() {
     bee.methodB();
  }
}

public class B {
  /**
   * The real stuff
   */
  public methodB() {
    // real stuff
  }
}
MonoThreaded
  • 11,429
  • 12
  • 71
  • 102

3 Answers3

91

Use hashes instead of dots, as in: @see B#methodB()

Miquel
  • 15,405
  • 8
  • 54
  • 87
  • What about in situations where we want to refer to a public static function of a class? Intellij IDE doesn't seem to recognize the `@see MyClass.foo()` format. Attempting to use a `#` results in `foo()` not being listed, as it is not a non-static member of `MyClass`. – Hatefiend Feb 04 '21 at 09:21
17

You need to use # instead of .

@see B#methodB()

See the documentation for @see here.

Curious
  • 2,783
  • 3
  • 29
  • 45
  • 1
    when I do this in Spring Tools Suite (eclipse derivative) I displays the reference but it is not a clickable link like a local method is. – JesseBoyd Jul 14 '17 at 15:51
7

This applies to javadocs in Eclipse.

Press # and Ctrl+Space to get a "link" to a Member-Method of current context.

In a Javadoc press

SDFCtrl+Space#gDFS Ctrl+SpaceSpaceSymbol

to create the link:

{@link SimpleDateFormat#getDateFormatSymbols() Symbol}
Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
Grim
  • 1,938
  • 10
  • 56
  • 123