Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325374

Summary: [content assist] Code assist should be smart enough to remove redundant parenthesis
Product: [Eclipse Project] JDT Reporter: Francis Upton IV <francisu>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P5 CC: alexis, daniel_megert, deepakazad, markus.kell.r, remy.suen
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Francis Upton IV CLA 2010-09-15 12:20:41 EDT
If you have code like this:

get()

And then put the cursor after the get and do an autocomplete, selecting getSomething(), you wind up with:

getSomething()()

Which is not what you want.

This can happen a fair amount if you are duplicating code just to change the method names.
Comment 1 Markus Keller CLA 2010-09-15 14:06:42 EDT
This doesn't happen when you have 'Completion overwrites' selected in the preferences (or hold Ctrl while inserting). Unfortunately, the Ctrl-toggling is not available when you have 'Insert single proposals automatically' enabled and Ctrl+Space only finds a single proposal.

Nevertheless, I agree this is a real problem.
Comment 2 Markus Keller CLA 2010-09-15 14:10:10 EDT
Note that there are also scenarios where you do want the additional arguments list, e.g.:
    get|(name)

and you want to change this to:
    getRemote(path, credentials).get(name)

=> in this case the () after getRemote are not empty but contain auto-filled arguments.
Comment 3 Dani Megert CLA 2013-04-09 09:37:48 EDT
*** Bug 405275 has been marked as a duplicate of this bug. ***
Comment 4 Alexis Pautrot CLA 2013-04-09 12:02:33 EDT
Another related bug (bug 405275) : with either 'Completion inserts' or 'Completion overwrite' options activated, code assist inserts redundant parenthesis when a space separates the cursor and its following parenthesis :

get<<CODE ASSIST>> (true);

will insert:

getSomething ( ) (true);

Maybe also related to options of my code formatter, where I'm using settings that put spaces before parenthesis.