Gaurav Agarwal
Gaurav Agarwal

Reputation: 19102

Is it possible to hyperlink comments in IntelliJ Idea?

I am using IntelliJ Idea for Android devleopment. Is there any way in which I can hyperlink two comments in the IDE. For example

File a.java

import a;

/**
* This class does something and something
* and does implements interface b, 
* (i want a hyperlink here, if pressed opens file b.java in IDE and cursor is at comments        
*  before method n)
*/

public class a {
  //do something
}

File b.java

import k;

public interface b {

   public j;
   public m;
   /**
    * This will be used when this and this will happen.
   */  
   public n;
}

Upvotes: 23

Views: 27506

Answers (3)

Michael Abyzov
Michael Abyzov

Reputation: 532

You can use just square brackets for that in the format: [class.method]. For your example it will be looked like this:

/**
* This class does something and something
* and does implements interface [b.n]
*/

Upvotes: 1

madmuffin
madmuffin

Reputation: 993

Current IntelliJ versions support the @link notation, just like Eclipse.

To link to another class/method, just use this pattern:

/**
 * {@link Class#method}
 */
public void myMethod() {
}

you can also spare the method, or add a list of argument types to the method (in parenthesis), useful if a method is implemented with different parameters and you want to link to a specific one.

Upvotes: 20

Vic
Vic

Reputation: 22041

You can use Javadocs' @see tag - examples here.

It should be sufficient to do something like that:

/**
* Bla bla bla
* @see b#n
*/
public class a

Upvotes: 23

Related Questions