Henrik Warne
Henrik Warne

Reputation: 2373

Is there a way in Intellij IDEA to see the name of the method the current line belongs to?

In our code base there are a few very long methods (several pages worth of code). When reading the code, it would sometimes be good to be able to see the name of the method the current line belongs to, without paging up to the beginning of the method. Is this possible in Intellij IDEA? I am using Intellij IDEA 7.0.3.

Upvotes: 84

Views: 21487

Answers (6)

Nate
Nate

Reputation: 31

In Intellij v2023.2.3 go to View -> Tool Windows -> Structure, click the "Options" (3 vertical dots) menu, and toggle on the "Always Select Opened Element". With that setting turned on the method will be highlighted in the Structure Tool Window if the cursor is placed anywhere within that method in the source code editor.

Upvotes: 3

CrazyCoder
CrazyCoder

Reputation: 401877

You can use View | Context Info (Alt+Q, Ctrl+Shift+Q on Macs). It will display a pop-up on the top of the editor with the current context information (class/method signature).

Upvotes: 103

ROMANIA_engineer
ROMANIA_engineer

Reputation: 56616

IntelliJ 2018

This is shown by default at the bottom.

Unfortunately, the method is shown only by name (not including the parameters). If a method is overloaded you won't know for sure where you are.

Method breadcrumbs below code area

If you want to move it from bottom to top, go to File > Settings... > Editor > General > Breadcrumbs > check Top:

Editor > Breadcrumbs > Show breadcrumbs

Upvotes: 80

desertSniper87
desertSniper87

Reputation: 890

Intellij now has support for breadcrumbs. Go to settings > appearance and tick "Show breadcrumbs". In this way you can view class/method name without Alt+Q.

Upvotes: 23

Jpaji Rajnish
Jpaji Rajnish

Reputation: 1501

For some reason (Alt-Q) wasn't consistent in Android Studio for me. I find (Ctrl-F12) to be pretty satisfactory for this purpose (Navigate|File Structure) though it can be a little laggy in larger files. And by pressing the hotkey again it will populate the list with all the inherited methods as well.

Upvotes: 2

Hugo Palma
Hugo Palma

Reputation: 3566

In the structure panel select the "Autoscroll from source" option. This way when you place the cursor inside any method the structure panel will show which method you're in.

Upvotes: 28

Related Questions