How to search for *only* methods in IntelliJ IDEA? - intellij-idea

I would like to have a way to search for methods in a class, only methods, not class member variables, is there a way to do that?.

Afaik there is not a dedicated way of doing this, but you can use the find action and search on a regex. E.g. something like: [ ][a-zA-Z]{2,}\(
With cmd+G you can navigate to the next occurrence. You can easily tweak the regex to search for public methods only if you like.
Alternatively you can press cmd+F12 to open the "File structure". (you can look it up in the keymap if you want to know the keyboard shortcut for other OS).
You will get more or less the same information when you write "this." and press the shortkey for autocompletion.
Tip: if you want to know if something is available you can always press shift twice and type what you are looking for. Check the "actions" section to see the available actions. Or press the cmd+shift+A to search for actions and options instantly.

Use Structural search. For java there is a pre-defined template for class methods exists (All methods of the class):

Related

What is the principle by which keyboard shortcuts selected in IntelliJ IDEA?

There are lots of useful functions of Intellij IDEA and for many of them there are keyboard shortcuts.
But remembering shortcuts may be difficult, at least for me.
Are there some consistent guiding principles by which these shortcuts were selected by designers? I believe learning such principles would be helpful to memorize shortcuts itself.
I think that the closest answer you're going to get is "it depends". Some shortcuts are obviously chosen, because the keybinding describes what the shortcut does, for example ⌘+O means open, not only in IntelliJ but in many places throughout OS X.
Some shortcuts probably don't have any kind of such semantic meaning, such as Alt+Enter and are chosen because they are very frequently used and the placement of the keys relative to each other is comfortable.
Other keyboard shortcuts with similar purpose have the same starting sequence of keys. For instance the extract refactoring shortcuts, which are as follows:
⌘+Alt+M - extract method
⌘+Alt+C - extract constant
⌘+Alt+V - extract variable
⌘+Alt+F - extract field
⌘+Alt+P - extract parameter
So in such case you only need to remember that if you want to extract something, you press ⌘+Alt and the first letter of what you want to extract.
That being said, I don't believe that the way to learning the keybindings is memorizing them, but using them. If you use one keybinding multiple times, over the time you will memorize it. You can help this process for instance by locating the action you want to perform in the menu, but instead of clicking it look at the keyboard shortcut next to it and press it. Or find the action using ⌘+Shift+A, look at the shortcut and use it.
There are even plugins, which can help you with this, for instance Key Promoter which you can install via Settings/Plugins/Browse Repositories. This plugin shows you shortcut you can use when you invoke some actions by clicking it in menu, etc. It also shows you how many times you've used this action in such a way instead of using the corresponding shortcut.

How place getter/setter methods at the bottom of a class definition in intellij

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

How to get call hierarchy for classes in IntelliJ?

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.

PhpStorm/IntelliJ generate method from usage

I'm looking for a generate method from usage. IntelliJ supports extract, rename etc. But if i write, for instance, $this->new_method($a) i would like to quickly generate this method in the same class. Does this exist or maybe there is a plugin for it?
Thanks for any help
Place cursor on non existing method
Alt + Enter (or wait and click on light bulb)
Choose Add method from submenu.

.NET - Find all references of property assignment

I am using VB.NET. In Visual Studio, if I right-click a property name and click "Find All References", it searches for all instances of the property being used.
However, a property is always used either for assignment (Set method) or retrieval (Get method). Is there any way of searching for only one of these uses? e.g. search for all uses of the property in code where it is being assigned a value, not when the value is being retrieved.
Use the compiler to turn what you want to find into errors. Remove the setter to find all the places were it was going to be used.
With Resharper, if you simply use the "Find Results" tool, and then there is a filter icon in the results window. You can then limit the results to only "Show Write Usages".
You can also use Reflector to browse through your assembly.
Resharper (MSVS addin) has the exact feature you are looking for.
Check:
ReSharper.FindUsages
or
ReSharper.FindUsagesAdvanced
in keyboard shortcuts mapping (Tools -> Options -> Keyboard) to find out what shortcut is used.