Fixed KT-6890 No autocomplete for receiver methods and properties in extension property
#KT-6890 Fixed
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.util
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
@@ -31,9 +32,14 @@ public fun JetScope.getImplicitReceiversWithInstance(): List<ReceiverParameterDe
|
|||||||
val withInstance = HashSet<DeclarationDescriptor>()
|
val withInstance = HashSet<DeclarationDescriptor>()
|
||||||
var current: DeclarationDescriptor? = getContainingDeclaration()
|
var current: DeclarationDescriptor? = getContainingDeclaration()
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
|
if (current is PropertyAccessorDescriptor) {
|
||||||
|
current = (current as PropertyAccessorDescriptor).getCorrespondingProperty()
|
||||||
|
}
|
||||||
withInstance.add(current)
|
withInstance.add(current)
|
||||||
|
|
||||||
val classDescriptor = current as? ClassDescriptor
|
val classDescriptor = current as? ClassDescriptor
|
||||||
if (classDescriptor != null && !classDescriptor.isInner() && !DescriptorUtils.isLocal(classDescriptor)) break
|
if (classDescriptor != null && !classDescriptor.isInner() && !DescriptorUtils.isLocal(classDescriptor)) break
|
||||||
|
|
||||||
current = current!!.getContainingDeclaration()
|
current = current!!.getContainingDeclaration()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
class A {
|
||||||
|
public fun foo(): Int = 1
|
||||||
|
public val bar: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
val A.abc: Int
|
||||||
|
get() {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: foo
|
||||||
|
// EXIST: bar
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class A {
|
||||||
|
public fun foo(): Int = 1
|
||||||
|
public val bar: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun A.ext() {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: foo
|
||||||
|
// EXIST: bar
|
||||||
@@ -823,6 +823,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("RecieverMembersFromExtAccessor.kt")
|
||||||
|
public void testRecieverMembersFromExtAccessor() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/RecieverMembersFromExtAccessor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("RecieverMembersFromExtFun.kt")
|
||||||
|
public void testRecieverMembersFromExtFun() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/RecieverMembersFromExtFun.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("SafeCallAfterNullable.kt")
|
@TestMetadata("SafeCallAfterNullable.kt")
|
||||||
public void testSafeCallAfterNullable() throws Exception {
|
public void testSafeCallAfterNullable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/SafeCallAfterNullable.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/SafeCallAfterNullable.kt");
|
||||||
|
|||||||
@@ -823,6 +823,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("RecieverMembersFromExtAccessor.kt")
|
||||||
|
public void testRecieverMembersFromExtAccessor() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/RecieverMembersFromExtAccessor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("RecieverMembersFromExtFun.kt")
|
||||||
|
public void testRecieverMembersFromExtFun() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/RecieverMembersFromExtFun.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("SafeCallAfterNullable.kt")
|
@TestMetadata("SafeCallAfterNullable.kt")
|
||||||
public void testSafeCallAfterNullable() throws Exception {
|
public void testSafeCallAfterNullable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/SafeCallAfterNullable.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/SafeCallAfterNullable.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user