Fixed extension functions being grayed in import statement completion
#KT-5627 Fixed
This commit is contained in:
@@ -314,9 +314,9 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
insertHandlerProvider, contextVariablesProvider)
|
||||
}
|
||||
|
||||
private fun detectCallTypeAndReceiverTypes(): Pair<CallType<*>, Collection<JetType>> {
|
||||
private fun detectCallTypeAndReceiverTypes(): Pair<CallType<*>, Collection<JetType>?> {
|
||||
if (nameExpression == null) {
|
||||
return CallType.DEFAULT to emptyList()
|
||||
return CallType.DEFAULT to null
|
||||
}
|
||||
|
||||
val callTypeAndReceiver = CallTypeAndReceiver.detect(nameExpression)
|
||||
@@ -338,9 +338,13 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
is CallTypeAndReceiver.SAFE -> receiverExpression = callTypeAndReceiver.receiver
|
||||
is CallTypeAndReceiver.INFIX -> receiverExpression = callTypeAndReceiver.receiver
|
||||
is CallTypeAndReceiver.UNARY -> receiverExpression = callTypeAndReceiver.receiver
|
||||
is CallTypeAndReceiver.IMPORT_DIRECTIVE -> receiverExpression = callTypeAndReceiver.receiver
|
||||
is CallTypeAndReceiver.PACKAGE_DIRECTIVE -> receiverExpression = callTypeAndReceiver.receiver
|
||||
is CallTypeAndReceiver.TYPE -> receiverExpression = callTypeAndReceiver.receiver
|
||||
|
||||
is CallTypeAndReceiver.IMPORT_DIRECTIVE,
|
||||
is CallTypeAndReceiver.PACKAGE_DIRECTIVE,
|
||||
is CallTypeAndReceiver.TYPE ->
|
||||
// we don't need to highlight immediate members in these cases
|
||||
return callTypeAndReceiver.callType to null
|
||||
|
||||
else -> throw RuntimeException() //TODO: see KT-9394
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
|
||||
class LookupElementFactory(
|
||||
private val resolutionFacade: ResolutionFacade,
|
||||
private val receiverTypes: Collection<JetType>,
|
||||
private val receiverTypes: Collection<JetType>?,
|
||||
private val callType: CallType<*>,
|
||||
private val isInStringTemplateAfterDollar: Boolean,
|
||||
public val insertHandlerProvider: InsertHandlerProvider,
|
||||
@@ -235,6 +235,7 @@ class LookupElementFactory(
|
||||
}
|
||||
|
||||
private fun callableWeight(descriptor: DeclarationDescriptor): CallableWeight? {
|
||||
if (receiverTypes == null) return null
|
||||
if (descriptor !is CallableDescriptor) return null
|
||||
|
||||
val overridden = descriptor.overriddenDescriptors
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package second
|
||||
|
||||
fun String.extensionFun(){}
|
||||
val Int.extensionVal: Int get() = 1
|
||||
|
||||
fun topLevelFun(p: (String, Int) -> Unit){}
|
||||
val topLevelVal: Int = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
package first
|
||||
|
||||
import second.<caret>
|
||||
|
||||
// EXIST: { itemText: "extensionFun", tailText: "() for String in second", attributes: "" }
|
||||
// EXIST: { itemText: "extensionVal", tailText: " for Int in second", attributes: "" }
|
||||
// EXIST: { itemText: "topLevelFun", tailText: "(p: (String, Int) -> Unit) (second)", attributes: "" }
|
||||
// EXIST: { itemText: "topLevelVal", tailText: " (second)", attributes: "" }
|
||||
+6
@@ -131,6 +131,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InImport")
|
||||
public void testInImport() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/InImport/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InImportedFunctionLiteralParameter")
|
||||
public void testInImportedFunctionLiteralParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/InImportedFunctionLiteralParameter/");
|
||||
|
||||
Reference in New Issue
Block a user