Summary: | Organize imports deletes needed static import. | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Brian Miller <Brian.Miller> | ||||||||
Component: | Core | Assignee: | Jay Arthanareeswaran <jarthana> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | normal | ||||||||||
Priority: | P3 | CC: | daniel_megert, kellyc, nanda.firdausi, Olivier_Thomann, satyam.kandula, srikanth_sankaran | ||||||||
Version: | 3.4.1 | Flags: | Olivier_Thomann:
review+
|
||||||||
Target Milestone: | 3.6 M5 | ||||||||||
Hardware: | PC | ||||||||||
OS: | Windows XP | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
Brian Miller
2008-10-28 10:54:24 EDT
Looks like a bug in the org.eclipse.jdt.core.dom.rewrite.ImportRewrite. Paste the following to get the test case quicker: package bug; import static bug.CaseType.all; import static bug.ShareLevel.all; import bug.CaseType; import bug.ShareLevel; class Bug{ public void createControl(){ for(CaseType cat:all()) cat.hashCode(); class Share{ Share(final ShareLevel sharing){ sharing.hashCode(); } } new Share(all); }; } package bug; enum CaseType{ one; static CaseType[]all(){return null;} } package bug; enum ShareLevel{all} Created attachment 155406 [details]
Patch for the problem
Jay, please review the patch and add regression tests. Created attachment 155715 [details]
Updated patch with regression test
The first patch looks alright. Ideally it would have been better to have the static import comparison in the ImportRewrite#compareImport(). However, I do see that we will have to move few things around. So left it that way and made one minor change (a variable name change) and added a regression test.
Created attachment 156258 [details]
Proposed fix
In the line:
(this.importsKindMap.get(curr.substring(1)).equals(this.importsKindMap.get(qualifier + "." + name)))),
is it sure that this.importsKindMap.get(curr.substring(1) cannot return null ?
I don't like to see 's' used for a prefix instead of using the constant field STATIC_PREFIX.
Also all strings should be either externalized or tagged with the NON-NLS tag.
I slightly change the patch. Jay, let me know whay you think.
If everything is ok, I'll release early next week.
Released the last patch for 3.6M5. Added regression test: org.eclipse.jdt.core.tests.rewrite.describing.ImportRewriteTest#testBug252379 Verified for 3.6M5 using Build id: I20100122-0800 Verified. |