1

As the topic. I'll repeat that because "As the topic." is less than 30 chars:

Does anyone know the trick in Anenter code heredroid Studio IDE that will let you go to a method(); in the code by [CTRL]B when the //method() is in comment?

// List of Methods:
// method1() this makes that
// medhod2() that makes this

private void method1(){
   //sth
}

// I click on method1() in the List/Comment 
// then by ([CTRL]B|Command-B) jump to the code...
Pablo_xyu
  • 31
  • 1
  • 7

2 Answers2

0

There is no direct way that I know of to go to a method that is named in a comment. You can, however, do something with a macro. There may be better ways to do this, but what I have done is to record a macro that does the following after positioning the cursor on the method I want to go to:

  1. Uncomment the line.
  2. Move cursor up. (This moves back to the method name.)
  3. Go to the declaration. (Editor is now at the declaration.)
  4. Jump back to the last change (ctrl-shift-backspace).
  5. Undo uncomment (ctrl-z)
  6. Go back to declaration. (ctrl-alt-back).

This was done with Android Studio 2.3.1 on Windows. You can assign a key to the macros from Settings->Keymap.

This is a little messy and a little risky in that it makes changes to your code, but It may be worth while to you if this is something that you do often and find useful. There may be other ways along the same lines that involve less risk.

Here is the macro I described. In Android Studio 2.3.1 macros are stored in config\options\macros.xml. I suggest that you record your own macro to work the way you want. You will also want to test to see what happens in the event of a failure such as when the method doesn't exist.

<application>
  <component name="ActionMacroManager">
    <macro name="goto_method_in_comment">
      <action id="CommentByLineComment" />
      <action id="EditorUp" />
      <action id="GotoDeclaration" />
      <action id="JumpToLastChange" />
      <action id="$Undo" />
      <action id="Back" />
    </macro>
  </component>
</application>
Cheticamp
  • 61,413
  • 10
  • 78
  • 131
0

However there is an another solution Alt+F7 which brings you all the detail even if it is used in comments.

Saveen
  • 702
  • 2
  • 14
  • 34