Project
IntelliJ IDEA
Priority
Normal
Type
Bug
Fix versions
10.0 (99.18)
State
Fixed
Assignee
Alexey Kudravtsev
Subsystem
Editor. Error Highlighting
Affected versions
No Affected versions
Fixed in build
98.328  
  • Created by   Vadim Spivak
    5 years ago (19 Aug 2006 00:53)
  • Updated by   Alexey Kudravtsev
    15 months ago (10 Nov 2010 13:54)
  • Jira: IDEADEV-13253
    (history, comments)
 
IDEA-33405 Change 'X' type to 'y.X' intention messes up imports.
0
Issue is visible to: All Users
  The issue is visible to the selected user group only
Here is a small example that shows the problem:

----------- a/b/Foo.java
package a.b;

public class Foo {
}

----------- a/b/FooFactoryB.java
package a.b;

public class FooFactoryB {
public static Foo getFoo() {
return new Foo();
}
}

----------- a/Foo.java
package a;

public class Foo {
}

----------- a/FooFactoryA.java
package a;

public class FooFactoryA {
public static Foo getFoo() {
return new Foo();
}
}

----------- a/Bar.java

package a;

import a.b.FooFactoryB;

public class Bar {

public static void main(String[] args) {
Foo aFoo = FooFactoryA.getFoo();
Foo foo = FooFactoryB.getFoo();
}
}



Now, in Bar.java, you will see the second statement in main underlined. The intention says 'Change 'foo' type to 'a.b.Foo'. When I select it, this is what happens:

package a;

import a.b.*;
import a.b.Foo;

public class Bar {

public static void main(String[] args) {
Foo aFoo = FooFactoryA.getFoo();
Foo foo = FooFactoryB.getFoo();
}
}



Which basically messes up the imports for the original Foo class. Also, in my code style I specified only to use the wildcard when there are 99 imports from the same package, so I'm not sure whats going on here. In my real world example, this is really annoying since I have a lot of references to the original class, and I have to use the local history to revert the changes to the imports.

Environment: Linux
Comments (1)
 
History
 
Linked Issues (?)
 
Bas Leijdekkers
  Bas Leijdekkers
01 Nov 2006 17:26
5 years ago
This is a problem with the quick fix not any intention (of IPP or otherwise).