Is there any way to jump to the method parameters from any point inside of this method?
You can use Navigate Between Methods and Tags and while with the cursor in the function:
On OSX: ^+↑
On Windows: alt+Up
which will move you to the next method header upwards — actually the current method — and then ctrl+Right or ⌥+→ to your parameters. No mouse / parameter usage lookup needed
Place the cursor on a parameter name within the method and press the following key combination.
On OSX: cmd +b
On Windows: ctrl + b
Related
I have this:
this.label = label;
I want this:
this.label = Objects.requireNonNull( label );
Is there a shortcut way to edit such a line rather than me typing in the Objects.requireNonNull() followed by cut/paste or dragging the variable to inside the parentheses?
I can imagine selecting the variable (label in this example), then pressing some keystroke that lets me type the method call, and upon hitting Return puts that var within the parens.
Surround live template
You can create a surround live template.
Surround templates wrap a block of the selected code with the text specified by the user. For example, T expands into a pair of tags, for which you can specify a name. You can also select a block of code, then press Ctrl+Alt+J to open the Select Template popup and select the T template to wrap the selection with a pair of tags.
Here is an example of creating your desired Objects.requireNonNull, here with abbreviated name ornn.
To invoke your live template:
Select the text you want to surround.
Press the keystroke currently designated for live templates.
You discover that needed keystroke by looking at Preferences/Settings > Keymap > Other > Surround with Live Template….
That shortcut would be…
macOS: Option + Command + J
Windows: Control + Alt + J
Structural Search
Another option would be to configure Structural Search and Replace inspection with the quick fix, then apply it via the Alt+Enter on the matched code.
Suppose I type a Java method call with an argument that I intend to make into a field:
knownObject.knownMethod(newField);
At this point, newField is highlighted as compilation error. I can press Alt+Enter and select "Create Filed 'newField'" from the menu.
That brings me up to the beginning of the class file where other fields are defined.
I can press Enter to confirm the new field's type.
Now I'd like to go back to my knownMethod() call and continue coding. How do I do that?
Bonus question: in the above situation, Ctrl+Shift+Backspace may help because I just edited the the knownMethod() call. What if I decide to first type in multiple arguments to the method? How do I get back to the argument I've just created a field for in that case?
For getting back to a previous caret location the Navigate > Back menu item usually works (CtrlAltLeft Arrow on Windows). Another option may be to use Edit > Find > Find Usages on the field (enable the Skip results tab with one usage checkbox setting)
I'm getting the above error trying to rename an array. Is there any other way? Trying this
Right click on variable -> Refactor -> Rename
I'm sure there has to be another way?
If you want to rename a local variable within a method or function and just want to rename all occurrences within that function, try this...
Click on the variable and leave your mouse there for a moment.... A down arrow will appear just to the right of the variable name. Click on that down arrow and choose "Edit All In Scope"
I want to delete the text present in the Java Edit box and want to add a new Text into that feild.
How can i perform this task in QTP (Scripting)?
#TestGeek
If you want to use "ctl+A and delete" sequence, use .Type() method of Edit object.
If your object is not fully supported by QTP and does not have .Type() method, you can use WshShell.SendKeys() as a workaround (don't forget to set focus on the object first).
In QTP, constants are defined with "mic" (Mercury Integer Constant) prefix. You can search for the full list in help.
For those, that you mentioned, you need the following:
micCtrlDwn
"A"
micCtrlUp
micDel
Try using the objects native function setText(""). This resets the contents to an empty string. The advantage is that is does the job in 1 line.
The .object allows access to the native methods, and a tooltip with all methods will appear in the qtp IDE only if the UI object is actually open on the screen.
JavaWindow("win").JavaInternalFrame("frame").JavaEdit("edit").Object.setText("")
I'm not very familiar with the Java add in but AFAIK the Set method replaces the text. If you really need to clear it first you can set to the empty string.
JavaWindow("win").JavaEdit("box").Set "" ''# Clear old text (optional)
JavaWindow("win").JavaEdit("box").Set "new value"
I accidentally changed something within the code style in my PhpStorm. Now, when I press Ctrl + Shift + F for formatting, a space is placed in front and after parameters in a method call within a function.
How can I change this back?
Go to Editor > PHP > Spaces > Within, see if "Function declaration parantheses" or "Function call parantheses" are checked.
In tab "Spaces", option "Within", desactive "Method declaration parentheses".