Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
}
like image 514
Gaurav Agarwal Avatar asked Dec 08 '12 14:12

Gaurav Agarwal


People also ask

How do I use jump function in IntelliJ?

To jump to the next or previous found issue in your code, press F2 or Shift+F2 respectively. Alternatively, from the main menu, select Navigate | Next / Previous Highlighted Error. IntelliJ IDEA places the caret immediately before the code issue.

How do I reference in IntelliJ?

Place the caret at the necessary code element and press Ctrl+Shift+P (or select View | Type Info from the main menu). If several expressions are available, select the desired one from the popup menu and press Enter .


3 Answers

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 
like image 131
Vic Avatar answered Sep 22 '22 09:09

Vic


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.

like image 37
madmuffin Avatar answered Sep 21 '22 09:09

madmuffin


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]
*/
like image 34
Michael Abyzov Avatar answered Sep 20 '22 09:09

Michael Abyzov