Bug 306568 - [ImportRewrite] Add Import does not work for nested type when package is on-demand imported
Summary: [ImportRewrite] Add Import does not work for nested type when package is on-d...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 306571
  Show dependency tree
 
Reported: 2010-03-19 14:34 EDT by Markus Keller CLA
Modified: 2010-04-27 10:40 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.97 KB, patch)
2010-03-30 13:35 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-03-19 14:34:59 EDT
HEAD

- default Organize Imports settings
- have this CU:

package xy;

import java.util.*;

public class Try {
    public static void main(String[] args) {
        HashMap h;
        
        Map.Entry e= null;
        Entry e2= null;
        
        System.out.println("hello");
    }
}

- set caret into "Entry" on the line with the compile error
- Source > Add Import
=> expected: "import java.util.Map.Entry;" should be added
=> was: no change

I think the problem is that java.util.Map.Entry now belongs to the java.util group, but that should only be relevant for grouping, but it doesn't mean that java.util.* actually imports java.util.Map.Entry.
Comment 1 Olivier Thomann CLA 2010-03-30 13:35:01 EDT
Created attachment 163430 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2010-03-30 15:30:07 EDT
Released for 3.6M7.
Markus, let me know if you find anything wrong. Besides the awkward use of the old behavior, it seems to work as expected.
Comment 3 Olivier Thomann CLA 2010-04-14 09:04:40 EDT
Added regression test:
org.eclipse.jdt.core.tests.rewrite.describing.ImportRewriteTest#testAddImports6
Comment 4 Jay Arthanareeswaran CLA 2010-04-27 10:40:52 EDT
Verified for 3.6M7 using build I20100424-2000.