Bug 307337 - [content assist] Default constructor should not be proposed for anonymous types
Summary: [content assist] Default constructor should not be proposed for anonymous types
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-29 01:53 EDT by Srikanth Sankaran CLA
Modified: 2010-04-26 14:30 EDT (History)
5 users (show)

See Also:


Attachments
Patch under consideration (3.62 KB, patch)
2010-03-30 07:17 EDT, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2010-03-29 01:53:59 EDT
3.6M6.

Try ctrl+space just before the comment in the code below.
The default constructor for class Test is one of the 
proposals. This is wrong and will lead to an error if
selected.
----------------------------------------------------------
public class Test
{
    Object obj = new Object()
    {
    	// completion here proposed the default constructor for test which is wrong.
    };	
}
Comment 1 Srikanth Sankaran CLA 2010-03-29 03:01:04 EDT
The default constructor proposal is synthesized by the UI
in org.eclipse.jdt.internal.ui.text.java.MethodDeclarationCompletionProposal.evaluateProposals(IType, String, int, int, int, Set, Collection) and is
not a direct proposal from the JDT/Core CompletionEngine.

Passing on to JDT/UI for comment and follow up.
Comment 2 Dani Megert CLA 2010-03-29 11:33:21 EDT
org.eclipse.jdt.core.CompletionContext.getEnclosingElement() returns the wrong context: instead of the anonymous source type it returns the initializer.
Comment 3 Srikanth Sankaran CLA 2010-03-30 07:17:33 EDT
Created attachment 163399 [details]
Patch under consideration

Ayush, please review.
Comment 4 Ayushman Jain CLA 2010-03-30 09:50:56 EDT
Patch looks good
Comment 5 Srikanth Sankaran CLA 2010-03-31 00:58:47 EDT
Released in HEAD for 3.6M7
Comment 6 Olivier Thomann CLA 2010-04-26 14:30:29 EDT
Verified for 3.6M7 using I20100425-2000