KT-7486 Auto import inserts qualified name in companion object
#KT-7486 Fixed
This commit is contained in:
@@ -273,18 +273,16 @@ public abstract class ElementResolver protected(
|
||||
private fun getAnnotationsByDeclaration(resolveSession: ResolveSession, modifierList: JetModifierList, declaration: JetDeclaration): Annotations {
|
||||
var descriptor = resolveSession.resolveToDescriptor(declaration)
|
||||
if (declaration is JetClass) {
|
||||
val jetClass = declaration
|
||||
val classDescriptor = descriptor as ClassDescriptor
|
||||
if (modifierList == jetClass.getPrimaryConstructorModifierList()) {
|
||||
descriptor = classDescriptor.getUnsubstitutedPrimaryConstructor()
|
||||
if (modifierList == declaration.getPrimaryConstructorModifierList()) {
|
||||
descriptor = (descriptor as ClassDescriptor).getUnsubstitutedPrimaryConstructor()
|
||||
?: error("No constructor found: ${declaration.getText()}")
|
||||
}
|
||||
else if (modifierList.getParent() == jetClass.getBody()) {
|
||||
if (classDescriptor is LazyClassDescriptor) {
|
||||
return classDescriptor.getDanglingAnnotations()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is JetClassOrObject && modifierList.getParent() == declaration.getBody() && descriptor is LazyClassDescriptor) {
|
||||
return descriptor.getDanglingAnnotations()
|
||||
}
|
||||
|
||||
return descriptor.getAnnotations()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
pl<caret>
|
||||
}
|
||||
|
||||
// ELEMENT: platformStatic
|
||||
@@ -0,0 +1,7 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
class A {
|
||||
platformStatic<caret>
|
||||
}
|
||||
|
||||
// ELEMENT: platformStatic
|
||||
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
companion object {
|
||||
pl<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// ELEMENT: platformStatic
|
||||
@@ -0,0 +1,9 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
platformStatic<caret>
|
||||
}
|
||||
}
|
||||
|
||||
// ELEMENT: platformStatic
|
||||
+12
@@ -107,6 +107,18 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PlatformStaticInClass.kt")
|
||||
public void testPlatformStaticInClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/PlatformStaticInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PlatformStaticInCompanionObject.kt")
|
||||
public void testPlatformStaticInCompanionObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/PlatformStaticInCompanionObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReplaceFunctionCallByProperty.kt")
|
||||
public void testReplaceFunctionCallByProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/ReplaceFunctionCallByProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user