Bug 201104

Summary: JavaElement of a recovered type binding should not return a compilation unit with no parent
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_audel, jerome_lanneluc, martinae
Version: 3.3   
Target Milestone: 3.3.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Regression test
none
Proposed fix + regression test none

Description Olivier Thomann CLA 2007-08-24 12:26:24 EDT
The parent of a compilation unit declaration should be a package fragment. Right now the java element of such java element has no parent. The CU is built using null as the package fragment.
Comment 1 Olivier Thomann CLA 2007-08-24 12:42:44 EDT
Created attachment 76926 [details]
Proposed fix

We use the IJavaElement of the package binding corresponding to the recovered type binding as the package fragment to build the fake compilation unit.
Comment 2 Olivier Thomann CLA 2007-08-24 12:43:17 EDT
Martin,

How does this sound?
Comment 3 Olivier Thomann CLA 2007-08-24 12:43:31 EDT
Created attachment 76927 [details]
Regression test
Comment 4 Olivier Thomann CLA 2007-08-24 13:14:29 EDT
Released for 3.4M2.

Jérôme,

Should this be a candidate for 3.3.1?
Comment 5 Olivier Thomann CLA 2007-08-24 13:14:56 EDT
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0283
Comment 6 Martin Aeschlimann CLA 2007-08-24 13:18:37 EDT
Sounds good to me! Thanks!
Comment 7 Jerome Lanneluc CLA 2007-08-27 05:00:20 EDT
+1 for 3.3.1 since clients never expect null as the parent of an ICompilationUnit. Not fixing this bug could cause NullPointerExceptions in client code. 
Comment 8 Olivier Thomann CLA 2007-08-27 09:56:02 EDT
Created attachment 77026 [details]
Proposed fix + regression test

Patch updated for 3.3.1.
Comment 9 Olivier Thomann CLA 2007-08-27 15:17:33 EDT
Reopen for 3.3.1
Comment 10 Olivier Thomann CLA 2007-08-27 15:18:47 EDT
Released for 3.3.1.
Regression test in org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0283
Comment 11 David Audel CLA 2007-09-03 09:10:36 EDT
Verified for 3.3.1 using build M20070831-2000.