Community
Participate
Working Groups
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 } };;; } }
*** Bug 304449 has been marked as a duplicate of this bug. ***
Probably not for 3.6.
*** Bug 318180 has been marked as a duplicate of this bug. ***
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?
Fixed in AnonymousTypeCompletionProposal. Available in builds >= N20100901-2000.
.
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).
Verified in I20100914-0100.