Bug 309022

Summary: [ImportRewrite] Add Import wrongly removes import for nested type
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, deepakazad, Olivier_Thomann, srikanth_sankaran
Version: 3.6   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 306571    

Description Markus Keller CLA 2010-04-13 12:38:19 EDT
HEAD, follow-up to bug 306568

- default Organize Imports settings
- have this CU:

package xy;

import java.util.*;
import java.util.Map.Entry;

public class Try {
    public static void main(String[] args) {
        HashMap h;

        Map.Entry e= null;
        Entry e2= null;

        PrintWriter pw;
        System.out.println("hello");
    }
}

- set caret into "PrintWriter"
- Source > Add Import
=> "import java.io.PrintWriter;" gets added (good)
=> "import java.util.Map.Entry;" gets removed (not good)
Comment 1 Markus Keller CLA 2010-04-14 08:38:20 EDT
Looks fixed to me in HEAD of ImportRewriteAnalyzer (and it fixes bug 306571).
Comment 2 Markus Keller CLA 2010-04-14 08:40:39 EDT
Reopening, I guess you kept this open to make sure you have a regression test for it.
Comment 3 Olivier Thomann CLA 2010-04-14 09:04:53 EDT
I released it yesterday, but I forgot to close the bug.
Released for 3.6M7.
Added regression test:
org.eclipse.jdt.core.tests.rewrite.describing.ImportRewriteTest#testAddImports7
Comment 4 Ayushman Jain CLA 2010-04-27 02:25:49 EDT
Verified for 3.6M7 using build I20100424-2000.
Comment 5 Srikanth Sankaran CLA 2010-04-27 06:02:02 EDT
Verified.