Bug 280801 - [content assist] Too many semicolons after constructor completion
Summary: [content assist] Too many semicolons after constructor completion
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 304449 318180 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-18 12:47 EDT by Markus Keller CLA
Modified: 2010-09-15 02:07 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2009-06-18 12:47:13 EDT
I20090611-1540

public class Try {
    Object m() {
        return null;
    }
}

- select 'null'
- type 'new Runna'
- Ctrl+Space
- press Enter to select the anonymous proposal for Runnable()

=> Result:

public class Try {
    Object m() {
        return new Runnable() {
            
            public void run() {
                // TODO Auto-generated method stub
                
            }
        };;;
    }
}
Comment 1 Dani Megert CLA 2010-03-04 03:07:37 EST
*** Bug 304449 has been marked as a duplicate of this bug. ***
Comment 2 Dani Megert CLA 2010-04-08 11:01:10 EDT
Probably not for 3.6.
Comment 3 Dani Megert CLA 2010-07-26 03:03:26 EDT
*** Bug 318180 has been marked as a duplicate of this bug. ***
Comment 4 Matthew Wilson CLA 2010-07-26 04:30:20 EDT
Note that, in 318180, there is only one semicolon produced, not two as in 280801.  In 280801, the extra semicolons are harmless; in 318180, the semicolons cause a compilation error.

The simplest solution is for Eclipse not to write out *any* semicolons on auto-complete of an anonymous class.

E.g.  I want to write the following method invocation:

   someMethod( someVariable );

I type:

   someMethod( sV

Then I hit Ctrl+Space, and select "someVariable" from the auto-complete:

   someMethod( someVariable

Then I close the parenthesis (if not configured to be automatically closed) and add a semi-colon:

   someMethod( someVariable );

Why, then, if I use auto-complete to create an instantiation of an anonymous class should it add *any* semicolons?
Comment 5 Dani Megert CLA 2010-09-01 11:44:34 EDT
Fixed in AnonymousTypeCompletionProposal.
Available in builds >= N20100901-2000.
Comment 6 Dani Megert CLA 2010-09-01 11:45:47 EDT
.
Comment 7 Markus Keller CLA 2010-09-03 06:56:52 EDT
Filed follow-up bug 324391.

The auto-insertion of ");" is handy e.g. if you create an anonymous and assign it to a variable:
    Runnable r= new Runn

But the heuristic should be defensive and only add the closing stuff when it is sure it will be necessary (i.e. err on the side of not adding).
Comment 8 Dani Megert CLA 2010-09-15 02:07:39 EDT
Verified in I20100914-0100.