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
|
container.getContainingDeclaration() as? ClassDescriptor ?: return false
|
||||||
else
|
else
|
||||||
container
|
container
|
||||||
val declaration = DescriptorToSourceUtils.classDescriptorToDeclaration(scope)
|
val classBody = (DescriptorToSourceUtils.classDescriptorToDeclaration(scope) as? JetClassOrObject)?.getBody()
|
||||||
return declaration != null && declaration.getContainingFile() == file && declaration.isAncestor(place)
|
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);
|
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")
|
@TestMetadata("PartiallyQualified.kt")
|
||||||
public void testPartiallyQualified() throws Exception {
|
public void testPartiallyQualified() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/PartiallyQualified.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/PartiallyQualified.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user