Netbeans hotkey to show overloaded version(s) of a Java method? - java

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.

Related

Smart commenting in an IDE (e.g. Netbeans)

Is there a way to mark a line of code which you can afterwards easily find by color, click or something similar?
Use-case: Suppose I want to mark every occurence of the word "radius" as to investigate how many radii are used so that I can differentiate clearly which one is which. In this case I would want to go through multiple files and mark the lines with the occurence of "radius" and afterwards (having marked -let's say- 32 radii) smartly go through them.
I'm specifically programming with JAVA in Netbeans. But any other IDE or even language would also be welcome.
Both IntelliJ IDEA and Netbeans have a full project search ( ctrl + shift + f )
I don't know how Netbean's approach looks like, but IntelliJ lists all occurrences of the string you type in, letting you easily jump to any occurrence you select.

Goto method of class shortcut

I have a tool that will list failed tests, and I would like a way to open a fully qualified class and goto a method in Eclipse with a single string I can copy from the results. It can use any pattern whatsoever (I can change the test results layout), but could be something like this example:
com.my.package.StringUtilTest:testValueOf
I shall use it for re-running tests, but could work with any methods. It could go to the first option when there are overloads (won't matter for me). It could also list all options and allow me to paste the string and enter to go to the first option (being the only one in my case), or selecting the correct one from the very narrowed down options, just like Ctrl + O will do (note Ctrl + O will work on current file only though). It could even accept (or require!) the parameter types, won't matter. Anything like that would be a huge thanks. Some place where I can paste a single string on (in any way that it may have to be) to open a specific method.
I've been looking for a while, could be built-in or configured shortcut, macro, plugin, et cetera, but could neither find nor wrap my head around doing something (not expert on eclipsetalities)... I tried searching for a lot different stuff, but as you can see my problem can be solved with a vast pletora of things (none of which I can find anywhere though).
Eclipse jdt doesn't have it yet, but I believe an open method dialog similar to the open type dialog is in the works.. Please create a bug at bugs.eclipse.org if one doesn't exist describing what you would want in such a dialog.

How to invoke method/constructor parameter hint in IntelliJ?

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.

NetBeans Java code completion is way too eager to please

Is it normal that the default behavior for code completion when editing Java is the following?
If I import a package, after typing the first ., any key I press results in the first item in the list being selected
Sometimes while typing keywords like public and protected, NetBeans will make some wild leaps and insert private after just a p or pu are typed!
In general, it tends to make some big guesses in terms of autocompletion, guesses that are not supported by my previous input at all.
I feel like this cannot be the desired behavior for every user. Is there a way to make the code completion not autocomplete anything, or at least make it way less eager?
Edit: To be clear, I do not want to have to disable the sometimes-useful "Autopopup Window." I want the window to eagerly appear with tips and suggestions for methods, syntax, whatnot - I just don't want NetBeans to try to guess what I want, because it is wrong 90 - 100% of the time.
Which version of Netbeans are you using because that doesn't seem to be the behaviour I am seeing in 7.1.
AutoCompletion popups don't appear until I hit Ctrl+Space.
If I type "p" and then hit Ctrl + Space, the popup shows "private", "protected" and "public". I can either keep typing (and the list gets smaller as possible matches are removed) or use the cursors to select the word I want and hit Enter.
If there is only one logical option e.g. I start typing "pu" and then hit Ctrl+Space, then Netbeans inserts "public" automatically (though this can be turned off).
Code templates are a different story, I have them set to be activated using Shift+Space. As far as I know, templates don't show any popups. Anyone who likes pain can consider changing the activation key to just Space :P
I definitely share your complaints, especially re: 1. A quick google search reveals ways to turn off autocomplete:
AutoComplete drives me crazy. I’ve always hated it – I feel like it
slows my computer down and sometimes it even seems to derail me in the
middle of typing something because the window comes up and somehow
snags focus. I turn it off under Options, Editor, General (uncheck
Auto Popup Completion Window).
Item 2) sounds more like the "code template" feature rather than the auto-completion.
If that gets in your way, you have two options:
change the key that "triggers" the code-template expansion (e.g. from "Space" to "Tab"
remove all two-stroke templates (or any other abbreviation that you would rather not have)
Both can be done under "Tools -> Options -> Editor -> Code Templates"

Eclipse "Set Next Statement"

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"

Categories

Resources