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

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

Related

IntelliJ constants.getProperty() autocomplete field

I have a large constants.properties file.
When reading properties from it with constants.getProperty("PROPERTY_NAME") I often have to copy/paste the property names which is rather long.
I see that IntelliJ is able to detect when properties are used inside the code, is it be possible to have auto-completion of property names when I type the name in getProperty()?
Yes, IntelliJ IDEA provides the completion for the Java Properties, use Ctrl+Space to get the hints:

How to search for *only* methods in 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):

Intellij Idea - Extract Class

Is possible in Intellij Idea 14 do something like in Eclipse: Refactor : Extract Class?
Or I should do it manually?
Not found proper option in menu, and I am startled option is not available.
Anything that's worth doing in eclipse can be done faster and easier in IntelliJ, but if you're used to eclipse then you'll have to work a little bit to understand IntelliJ's way of doing things.
If you place your cursor somewhere in the java code in question (or on the class name in the project window), the Refactor menu will have an Extract option. Extract Delegate, Interface, and Superclass are the three options that deal directly with classes. These menu options aren't available if your cursor isn't in java class code.
The Interface option extracts an interface, renames your class and makes it implement the interface. The 'Superclass' option extracts a superclass and changes references to refer to it rather than your, now, derived class. The Delegate option simply extracts the methods and properties you choose into a new class.
Place your cursor onto the name of your inner class and press F6.
The refactoring you are looking for is probably extract delegate.

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.