Bug 107409 - [move member type] incorrect imports with double nested class
Summary: [move member type] incorrect imports with double nested class
Status: CLOSED DUPLICATE of bug 310510
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 150064 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-19 03:24 EDT by David Pérez CLA
Modified: 2014-06-24 22:30 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Pérez CLA 2005-08-19 03:24:14 EDT
Hi,

I have this class

package a;

class A {
   class B {
      class C {
      }
   }
}

Then I place the cursor over the B class and execute the "Move member type to
new file" refactoring.

It works well, but in the new file B.java I have this incorrect import sentence:

   import a.A.B.C;

that should be omitted, because C is a nested class from B directly accessible
without any import sentece.
Comment 1 Mauro Molinari CLA 2007-08-27 11:27:00 EDT
Hi,
I just tried David's example, but I have no errors when converting B to Top-level with Eclipse 3.3.

However, I found another example where the problem certainly occurs:

package a;

public class A
{
  public static class B
  {
    void b(C c)
    {
    }
    
    public class C
    {
    }
  }
}

Now, select B and choose "Refactor => Convert Member Type to Top Level", hit OK. The result is:

package a;

import a.A.B.C;

public class B
{
  void b(C c)
  {
  }
  
  public class C
  {
  }
}

and the import line gives a compilation error.
The problem arouses when B has a method with a parameter type that refers to C. If you remove b(C) method, the result is correct.
Comment 2 Martin Mathew CLA 2014-06-24 22:22:18 EDT
*** Bug 150064 has been marked as a duplicate of this bug. ***
Comment 3 Martin Mathew CLA 2014-06-24 22:30:56 EDT

*** This bug has been marked as a duplicate of bug 310510 ***