If I write code sequentially, then after I enter some method call and opening parenthesis, I get a hint after delay:
if I discard it or return to the place later, I see no any hint:
How to invoke it without retyping the code?
Ctrl+P will give you a pop-up with the method parameters. Usefully, the parameter corresponding to your cursor position will be highlighted and will change as you move back and forth through the parameters.
Intellij provides a lot of assistance. See here for a summary of what's available.
I faced the same condition in the earlier days.
No need to retype the complete code but just retype the comma(,) intellij is intelligent enough to guess the next variable value and suggest you better. I used this many times so far and made me to save my time in all instances.
Hope i was useful.
On Mac the shortcut is ⌘ (Command) + P.
It works fine.
Related
I find this extremely annoying that you often do not get help with figuring out the parameter signatures of methods and contructors when you have already written the first parameter.
Instead Intellij will show the variables available to you in your context. This is good, but not the first prio. I want to see the signature of the method/constructor as well.
This has the consequence that you always have to keep deleting and CTRL + SPACE to see the signature.
Is there a way around this issue?
You don't have to press Ctrl+P, you can configure IDEA to always show this information:
Go to Settings > Editor > General > Code Completion
Select the Show full signatures and Autopopup in (ms:) boxes.
You can press Ctrl+P to show the signature(s) of the method/constructor, see this link for more details:
https://www.jetbrains.com/idea/webhelp/viewing-method-parameter-information.html
I look for some trick which gives me possibility to change the syso behaviour in Eclipse (please assume that below there is Eclipse´s editor), now it works in this way:
syso%someVariable
% - means the plase when i typed ctrl + space, and result is:
System.out.println();someVariable
but I want to have of course without copying text..:
System.out.println(someVariable);
Any hints ? :-) Thanks in advance !
Reference
The feature is called "code templates" in Eclipse. You can add templates with Preferences->Java->Editor->Templates. Two good articles:
http://eclipse.dzone.com/news/effective-eclipse-dont-write-c
http://eclipse.dzone.com/news/effective-eclipse-custom-templ
Also, this SO question:
Useful Eclipse Java Code Templates
System.out.println() is already mapped to sysout, so you may save time by learning a few of the existing templates first.
If you wan´t to change current template you can press shift + end (to select 'someVariable') and then press ctrl + space and up, enter to select sysout.
Answering the original question or at least how I understood it:
Modify the existing template syntax for sysout (Preferences->Java->Editor->Templates find sysout and select edit) to read:
System.out.println(${cursor});
Now you can type syso and then ctr+space and instantly get the output:
System.out.println(<cursorHere>);
Or as you put it:
System.out.println(someVariable);
...with the cursor inside the brackets which is indeed more efficient than starting after the semicolon.
At the moment, when write code and get into a method that has many overloaded versions, Ctrl-Space will display the overloaded list as snapshot #1 below.
After I choose one version, I want to switch to another overloaded version but I don't know what hotkey to reshow the overloaded list, as shown in snapshot #2. Currently I have to delete the arguments and hit Ctrl-Space again which is quite tiring to me.
What is the hotkey to reshow that list then?
I think there's no way to do what you want. I took a look at the shortcuts configuration and didn't find anything.
Ctrl + Space is related to code completion. Hitting Ctrl + Z again can work if you selected the method with less parameters.
Maybe the best alternative is to hit Ctrl + Z after the wrong completion. It will restore the state just before the wrong selection. Then hit Ctrl + Space again.
Is there a way to jump to a line of code in Eclipse for Java?
It would be useful for re-running a function to debug.
Something like Visual Studio's "Set Next Statement" or the draggable yellow arrow?
When in the debugger select a place in the stack, right click, and select "Drop to Frame". This will unwind the call stack. You can do this on the current method (top of the call stack) to unwind to the top of the method. This doesn't work all the time for various reasons but you can do it pretty often.
This feature does not exist even conceptually in the JVM Tools Interface, much less in the Java Debug Wire Protocol that IDEs tend to interface with. Implementing it in an IDE would require creating (and mantaining) a custom build of Hotspot/JRockit/etc itself.
I also have not found it, and don't think it is supported. It's availability in Visual Studio (for C++ development) really spoiled me. It is very useful on occasion.
I'm unaware of any means to do so in Eclipse - and all obvious checks turn up nothing. I suspect there's an issue with how java works, as it's been available an awfully long time in Visual Studio and for Eclipse to have not matched it means it must not be a heavy task but an epic one.
I have found one rather silly way to rerun a method without going back to the previous frame.
e.g. you are in this function:
'public int compareTo(EVAL evalOther) {
int jRet = compareId(this.id, evalOther.id);
if (jRet == 0) {
jRet = compareXYZ(this.XYZ, evalOther.XYZ);
}
return jRet;
}'
let us say, after executing the first line, i.e.
int jRet = compareId(this.id, evalOther.id);
I want to rerun this line, I just make a minor change to it which will force a quick recompile of the same method . So it starts from the first line of the method again.
e.g. I change the line
'int jRet = compareEVALClass(this, evalOther);'
to
'int jRet = 0 + compareEVALClass(this, evalOther);'
Press Ctrl-S (or whatever your shortcut key is to Save file)
And then the function recompile and will restart from the first line again.
Agreed, this is not as great as Visual Studio's "Set next statement"
I need help with this:
I have autocompletion set so it pops up after every key being pressed. The problem is with ordering of hints, I would realy need the keywords, being first in the list. How can I do that?
There is one another related issue for example I write final keyword, and it is not first in the list, so I have to press Esc, is there any way to insert completely matched word without ending up with 30 letters long fully classified class name in place of the intended one?
Thank you for help.
The Eclipse preferences give you limited control over this behavior. What you can modify via the UI can be found under the preferences at Java/Editor/Content Assist, and Java/Editor/Content Assist/Advanced.