I have two methods in my code base. I would like to figure out, if there exists a path in which one will be called from the other. Is there some way to achieve this easily in IntelliJ without digging manually through call hierarchies?
The following might work for you on IntellIJ IDEA 16 and higher. It uses call hierarchies, but automates the digging;-)
invoke Call Hierarchy Ctrl+Alt+H on method 1.
click on the Callee Methods Hierarchy button in the tool window that appears to show all methods that are called by method 1.
click on the Expand All button a couple of times to show called methods until the desired depth.
Invoke Find Usages on method 2 and select the Scope Hierarchy 'Callees of 1'
Result: all calls of method 2 in method 1's call hierarchy.
I've done the following:
Select method 2 and invoke call hierarchy with Ctrl+Alt+H.
Click Expand All on the hierarchy panel
Click inside the hierarchy panel, and start typing the name of method 1
Related
Look at this picture, I should open the Structure window every time in Intellij Idea whenever I want to know methods in the class.
Is there a simple way or shortcut to show methods quicky what like CTRL + O in Eclipse.
Ctrl+F12 should pop up a member list. It will respond to text input to search/filter, too.
I use the Generate function in the context menu to create my getter and setter methods. But there seems no way to tell Intellij to place the generated methods after the last method in the file ie at the bottom of the class definition. This is possible in Eclipse. Anybody know how to do it automatically in Intellij?
First of all a little hint. IntelliJ is designed to use without a mouse, so I prefer using the keyboard-shortcut Alt + Insert for code generating.
I don't know any possibility to generally define the place for inserting generated code. I recommend to place the cursor there, where you want to insert generated code and then generate it.
If you want to generate getters and setters via Generate menu, the only way is to place cursor at the bottom of your class (or wherever you want them to be)
But if your field is not used yet, there is another option: navigate to the field you need getter/setter for, press Alt+Enter (it calls intentions dialog) and choose "generate getter and setter" option. Then getter and setter will be generated at the bottom of the class (but not below inner classes if any).
settings > code style > java > arrangement
lets you customize the auto formatting options
I just moved to IntelliJ from Eclipse. I know how to get call hierarchy for methods (by pressing Ctrl+Alt+H), however, I can't get call hierarchy for classes (not type hierarchy), when I press Ctrl+Alt+H on the class name, nothing happened, when I use navigate->call hierarchy, the menu entry cannot be clicked (gray color). I need to know where the class gets called/initialized. This cool feature is in Eclipse, so I think IntelliJ also has this too.
You should be able to do the call hierarchy on a constructor. Alternatively, I've always found a usage search more useful than the call hierarchy.
Press Alt+F7 on a class, method, or field or right click and select "Find Usages". The results are categorized (new instance creation, type parameter, import, etc) so it's extremely simple to find what you're looking for.
how do I find in XCode all caller functions of a specific function like eclipse's Call Hierarchy
Since the release of XCode 4.4, this functionality exists and is called "show related items".
There are multiple ways of accessing the pop-up menu that will allow you to view all callers and callees, among other things.
The fastest way is:
Mark method in code (using your cursor or double click name)
Press Ctrl+1
Select "Callers" from the pop-up menu
You can also go View->Standard Editor->show related items or press the tiny button just left of the arrow buttons in the line just above the editor window (where it shows your currently selected file and method).
There is a hotkey —> ^CmdShift + H
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.
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).
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.
If you want to move it from bottom to top, go to File > Settings... > Editor > General > Breadcrumbs > check Top:
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.
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.
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.