NetBeans parameter fill after code completion - java

This is a particularly annoying problem I'm having, and I can't be the only one to have issue with it.
In NetBeans, when you type part of a method, then hit CTRL-SPACE, it displays the code-completion popup, whereupon you can hit tab to finish out the word. This is great, and pretty much how all IDE's operate.
Example:
Thread.sl
< CTRL-SPACE >
Thread.sleep
Yay!
Problem is that in this context, once you type in a paren, it auto-fills the parameters for the method with their default names, and inserts a closing paren (regardless of whether you have disabled the option to automatically close them on the preferences page for code completion). This behavior is NOT present if you had manually typed out the full name.
How is this helpful to anyone? You've got to type over it your actual variable that you will be passing, and NetBeans gives you no option to prevent the closing paren on code-completion.
Does anyone have a way to solve this issue, without having to dive into the netbeans source and build it just for this minor of an issue?

inserts a closing paren (regardless of
whether you have disabled the option
to automatically close them on the
preferences page for code completion).
That option is for brackets, not parentheses.
Does anyone have a way to solve this
issue, without having to dive into the
netbeans source and build it just for
this minor of an issue?
Remove the opening parenthesis from the list of completion selectors.
alt text http://img411.imageshack.us/img411/7287/netbeanscodeassist.png

What version of netbeans do you use ?
For me (NB 6.9 RC1), when I code complete a method with parameter, I can edit one by one all parameters with RETURN to go from one to another. It's very easy, and the suggestings parameters are 1/2 times corrects.
See Suggesting Parameters at Code Assistance in the NetBeans IDE Java Editor: A Reference Guide / Smart Code Completion

Related

The cursor randomly disappears in Eclipse 2019-09 and sometimes stops writing

I have a very annoying problem with Eclipse 2019-09 (4.13.0) version: while I'm editing code (often when I copy and paste things or after accepting a code completion suggestion) the cursor (I'm talking about the text cursor: |) disappears completely! I cannot see it anymore, so I'm not able to detect on which part of the line I am! This is very annoying. I found a partial fix by installing the extension 'Vrapper': enabling and disabling it makes the cursor appear again.
Another problem I experience every time I press Ctrl+Space to ask for code completion suggestions, the cursor stops writing. After doing random things like switching tabs or opening new files the cursor starts to write again, but then the keyboard shortcuts stop working and I have to restart the entire IDE.
This behavior is intolerable, so I was wondering whether somebody else has had the same problem and how they have dealt with it.
The configuration of my system is:
OS: Debian, using i3wm+compton as a window manager on Xserver.
Thanks in advance.
Dead place, but I'm currently dealing with the same. The weird thing is that it happens on a per-file basis. Eclipse also treats that file as if it was not open, i.e. I can only save it through the 'Save all' method, not Ctrl-S ('Save') as I usually do. It's hellishly annoying, but it usually is fixed by reopening the file in question, and editing other files between the closing and reopening of other files.
If you have a better answer than this that you've found since, please, please post it here. It's annoying as all hell.
Minimize eclipse and maximize again.
Happened to me on Eclipse 2022-09 (4.25.0).

I can't figure out how to disable Netbean's code completion without disabling pop-up of suggested code

How do I disable code completion but keep suggestions enabled? Every time I type object.Method() without passing any parameters I get something similar to object.Method(datatype). Netbeans would complete the code after the first parenthesis, (. When I don't want to pass any parameters, I simply type ) once. I would get something like this thanks to auto complete: object.Method())
The null in between () would be replaced by the ) I typed.
I want to be able to see suggested code without ctrl-space and without having netbeans automatically insert the code for me. In netbeans I can disable the auto insertion of the second bracket } after I type the first {. I don't have an option to disable parentheses from auto inserting. The problem is that if I disable code completion, I also disable the automatic pop-up that gives me related code. Any advice?
If you do not want the IDE to perform the project updates, you can disable the build analyzer as follows:
Right-click the project node in the Projects window and select Properties.
In the Project Properties dialog box, click the Code Assistance category.
Deselect the Use Build Analyzer option.
https://netbeans.org/kb/docs/cnd/HowTos.html
It's been awhile since I used NetBeans (personally I prefer IntelliJ), but I believe you're using the wrong setting. Try this: under Tools>Options>Editor>General, uncheck "Insert Closing Bracket Automatically".
See also this other question: NetBeans curly braces auto-closing

Automatically open Content Assist in Eclipse when removing wrongly typed letters

Is there a way to open Java Content Assist in Eclipse, when pressing backspace (i.e. removing wrongly typed letter)?
Consider an example: When we type this., the Eclipse opens Content Assist windows with code completion suggestions. Then if we write a text, that is not suggested (e.g. it suggests a series of get* methods, and we type this.gw), the Content Assist window disappears. Then when we press backspace to remove wrongly typed letter, the assist window remains closed.
Is there a way to automatically reopen this window? Is there a setting in preferences for this?
I know that ctrl+space brings back Content Assist window, but that's not a solution. I just want more friendly behavior of IDE, known from e.g. Visual Studio.
How about pressing Ctrl+z instead of backspace? IIRC that should do the trick.
By default, content assist is automatically activated by '.'. To get around this issue, you could either delete all the way down to '.' and retype the period or change the way eclipse activates content assist.
You can do this by changing the 'Auto activation triggers for Java' setting under Preferences->Java->Editor->Content Assist from '.' to all the letters of the alphabet. This would take care of the issue but might introduce other unwanted behavior.

Disabling Eclipse auto-complete but keeping auto-activation

I use Eclipse for Java development. I like the auto-activation feature because I can add all the letters and numbers so I can see class members while I'm typing; making it behave similarly to Visual Studio. If I don't add all of the letters and numbers to the auto-activation list, it will only pop up with class information when I'm typing the first letter after the '.' delimiter, and then it disappears.
The real problem arises when I'm typing in a variable name or something else. As soon as I hit space, the auto-complete types a bunch of crap following what I've typed in attempt to complete it. It's driving me crazy!
Any way to turn this off?
The checkbox you have to check is: "Disable insertion triggers exept 'Enter' "
(under Java -> Editor -> Content assist)
I'm on Eclipse 2018-12 and C_H's answer had no effect on the behavior:
I believe what you'll want is to deactivate "Insert single proposals automatically"
EDIT: It seems this answer is now outdated. It may work for old Eclipse versions. For any more recent versions refer to #ChrisP's answer from 2019.
Open menu Window, then Preferences. Follow path Java -> Editor -> Content assist. Now mess around with the settings to find your ideal setup. I believe what you'll want is to deactivate Insert single proposals automatically.
If anyone wants to know how to stop the auto-complete for brackets:
Toggle off: "Edit --> Smart Insert Mode"
Version: Eclipse Photon
In continuation to #G_H's answer :
This worked for me although I am sure there is another and a better way.
Window -> Preferences -> Java -> Editor -> Content Assist -> Set Auto Activation Delay(ms) : 200ms from 0ms in my case.
You may want to increase/decrease the value 200 depending on your typing speed.
The reason this worked is because of the hitting of "Spacebar" before the delay arrives.

AutoIndent in Eclipse possible?

I have been wracking my brain trying to figure this out. For the first time I used jEdit the other day and I was pleasantly surprised that it auto indented my code (meaning that I'd put in the following code:
int method () {
_ //<-- and it put me here automatically
I've tried to get the same thing working with eclipse but with no success. I got into the code formatter but I don't see how to make that happen.
Is it possible to do this? Also while I'm here, is there a such thing as a eclipse plugin that will allow you to search the methods and classes of the standard java library?
Thanks
Personally all I use for this is the format options Window->preferences under Java->Code Style ->Formatter.
I once took the time to tweek how I like my code to look like when I work and exported the whole thing. After that I just code without too much bother on what it looks like. When I find the code looks messy by pressing the combination ctrl+shift+f and the whole class becomes pretty again, comments and all.
After a while it pretty much became a reflex...
code code code
ctrl-s, ctrl-b (cause I disable auto build sometimes), ctrl-shift-f
code some more etc...
Once I got used to this I never really cared how it presented the code as i was typing because I knew it would look all pretty as soon as the loop/if/switch/method etc is finished
My clean eclipse install does this by default.
Have you changed any options? Make sure the file you are editing has the .java file extension. The preference options that control the typing automations are under Java -> Editor -> Typing in the Window -> Preferences menu.
Also, I find that the auto-indenting, and most of the other auto-complete functions of eclipse do not function well if the file I am editing has errors in it which prevent compilation. Make sure that your curly-braces are matched correctly, this is the main one that I've noticed blocks auto-indent.
Regarding searching through the standard Java libraries, use the Search -> Java.. menu option, and check the JRE libraries checkbox, then search away. You can also use the Hierarchy view to see how the classes relate. Also, in the Package and Project views you can expand the JRE System Library, and then expand rt.jar which holds pretty much all the standard Java pacakges.
Eclipse has always done this for me by default.
One really cool thing about eclipse is that you can search preference pages. Just right click and go to prefrences. Go to the "Window" menu, and click "Prefrences". Then at the top of the tree view there's a text box that says "type filter text". Replace that with "indent" and it should bring up the page where the indent option is.
Make sure that eclipse recognizes your file as a java file, that you're using the Java distribution, the latest version, etc.
Iv been trying to work around the eclipse indenting and other supposed features for years, and it seems that the bottom line is this ...
It only works for the programming style of the authors, so to use it you need to modify your style to comply.
This would be OK except that the authors of eclipse have some very strange ideas about common shortcut keys.
One horrid example is the search features, eg when did Ctrl+K become "Find Next occurrence" and why doesnt F3 or n work?
That all being said I use eclipse because if you have the time to wait around while it starts up - or never close it - and you can modify everything youve learned about using an editor - why why why - then it will certainly increase your efficiency.
Please note that there is a preference setting for indenting, it can be set for a project, a workspace, or globally, but no matter how you set it eclipse will still chuck tab characters in where you dont want them.
In fact its indent crazy, like it wants to indent everything, even if its already indented.
Like I said Iv been using it for years and it STILL drives me nuts with its random behavior.
Follow these steps for Eclipse:
Select all text: ctrl+A
Correct indentation: ctrl+I
You should check:
Hidden features/tricks for Eclipse?
What is your favorite hot-key in Eclipse?

Categories