Optimize imports: fixed bug with references in class declaration header
This commit is contained in:
@@ -216,8 +216,8 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
container.getContainingDeclaration() as? ClassDescriptor ?: return false
|
||||
else
|
||||
container
|
||||
val declaration = DescriptorToSourceUtils.classDescriptorToDeclaration(scope)
|
||||
return declaration != null && declaration.getContainingFile() == file && declaration.isAncestor(place)
|
||||
val classBody = (DescriptorToSourceUtils.classDescriptorToDeclaration(scope) as? JetClassOrObject)?.getBody()
|
||||
return classBody != null && classBody.getContainingFile() == file && classBody.isAncestor(place)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ppp
|
||||
|
||||
import ppp.Base.Nested
|
||||
|
||||
class Base(p: Nested) {
|
||||
class Nested
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package ppp
|
||||
|
||||
import ppp.Base.Nested
|
||||
|
||||
class Base(p: Nested) {
|
||||
class Nested
|
||||
}
|
||||
@@ -139,6 +139,12 @@ public class OptimizeImportsTestGenerated extends AbstractOptimizeImportsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NestedClassReferenceOutsideClassBody.kt")
|
||||
public void testNestedClassReferenceOutsideClassBody() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/NestedClassReferenceOutsideClassBody.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PartiallyQualified.kt")
|
||||
public void testPartiallyQualified() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/PartiallyQualified.kt");
|
||||
|
||||
Reference in New Issue
Block a user