Tell Eclipse to auto-complete only method name?
Asked Answered
K

2

14

Let's say I'm editing a line...

obj.fooBar(x, y, z);

I want to change the method name to fooSomethingElse, but keep most of the arguments. If I delete all or part of the name, and then use content assist, it completes the method name, but starts a new arg list...

obj.fooSomethingElse(arg1, arg2)(x, y, z)
                     ^---- this arg is highlighted for editing

I often have to delete "(arg1, arg2)". I can turn off "fill method arguments" in preferences and then I only have to delete "()", but it's still annoying. Is there another command to complete only the method name. Ideally it would just be a separate command and key combo from the general purpose content-assist, so I can invoke either one as needed.

Kristiekristien answered 9/7, 2012 at 15:49 Comment(0)
S
17

Essentially you are looking for a way to toggle between inserting and replacing via content assist. The default behavior is to insert. You can toggle this behavior while inside the content assist selection dialog by pressing and holding the Ctrl key while selecting the completion.
More inforation - http://blog.deepakazad.com/2012/06/jdt-tip-toggle-between-inserting-and.html

Shanly answered 9/7, 2012 at 15:56 Comment(2)
Yup that's hit, hold down control while I hit enter, to select one of the methods, and it does what I want. Thanks.Kristiekristien
I find the IntelliJ approach easier to use: enter to insert, tab to just replace (This way is little time consuming)Faythe
S
0

I think you just need to press tab instead of enter to autocomplete it. Then it will keep your existing parameters.

Siglos answered 9/7, 2012 at 15:51 Comment(3)
I'm Eclipse 4.2, Mac OS, and that doesn't work. Tab simply highlights one of the methods in the popup list.Kristiekristien
Tab doesn't work in Windows either, it just changes focus. Holding CTRL works fine.Fantasy
This works fine in intellij based IDE.. haven't found it working in eclipseFaythe

© 2022 - 2024 — McMap. All rights reserved.