PhpStorm/IntelliJ generate method from usage - intellij-idea

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.

Related

How to move cursor to Vue methods, computeds, data quickly in VS Code?

I already tried using the symbol explorer in VSCode (CTRL+P then write #). It allows me to jump to data (because it's a method) but it won't jump to normal properties like "computed:" or "methods:"?
This would be useful when eg. I look at my component and think "Aha! I need to add a computed, so let's jump to computeds". I could just CTRL+F but this sometimes doesn't work if another variable or comment has 'computed' in its name
Currently, you can
use Ctrl+R to open Go To Symbol in Editor,
then enter some words like data, computed or methods and etc.,
then press Enter
The cursor would be moved to the selected symbol. Tested in Win10/v1.48.2
The easiest way how to do that is probably using Bookmarks extension.
I am using them and also I haven't find a better way how to solve same problem as you have.

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):

How to show all methods quickly in Intellij Idea?

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.

Adapt the extend selection in IntelliJ

Everyone knows that when you select some text in IntelliJ and press Ctrl+w your selection is expanded.
However,
you're kinda stuck on the presets for this:
when you have following code:
<a4j:commandButton execute="#form" render="tableProperties"
value="#{cjr_main.addExtractType}"
action="#{ExtractTypesBean.addExtractType()}"
styleClass="bigButton"
oncomplete="setLineAdded();"/>
and "Line" is selected but the method setLineAdded() is not yet defined you'd want "setLineAdded()" to be selected after hitting ctrl+w a couple of times.
However
Once "setLineAdded" is selected, and you press ctrl + w the whole tag is selected in stead of the accompanying "()"'s...
Is there a way to get this behavior?
(without writing a whole IntelliJ plugin just for this?)
best regards,
S.
No, the behavior of extend selection is controlled by code and is not configurable by users. You can indeed write a plugin to change the behavior.

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