diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirCompletionContributor.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirCompletionContributor.kt index 26a860d57c4..0ecf9328074 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirCompletionContributor.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirCompletionContributor.kt @@ -72,36 +72,46 @@ private object KotlinFirCompletionProvider : CompletionProvider) { - val expectedReceiverType = symbol.fir.receiverTypeRef?.coneTypeUnsafe() + val expectedReceiverType = symbol.fir.receiverTypeRef?.coneTypeUnsafe() - if (expectedReceiverType != null) { - val receiverTypes = if (explicitReceiverType != null) { - listOf(explicitReceiverType) - } else { - towerDataContext.nonLocalTowerDataElements.mapNotNull { it.implicitReceiver?.type } - } - - val expectedReceiverTypeIsPresent = receiverTypes.any { - AbstractTypeChecker.isSubtypeOf(completionContext.session.typeContext, it, expectedReceiverType) - } - - if (expectedReceiverTypeIsPresent) { - result.addElement(LookupElementBuilder.create(name.asString())) - } - } else if (explicitReceiverType == null || symbol.callableId.classId == explicitReceiverType.classId) { - result.addElement(LookupElementBuilder.create(name.asString())) + if (expectedReceiverType != null) { + val receiverTypes = if (explicitReceiverType != null) { + listOf(explicitReceiverType) + } else { + towerDataContext.nonLocalTowerDataElements.mapNotNull { it.implicitReceiver?.type } } - } - scope.processFunctionsByName(name, ::processor) - scope.processPropertiesByName(name, ::processor) + val expectedReceiverTypeIsPresent = receiverTypes.any { + AbstractTypeChecker.isSubtypeOf(completionContext.session.typeContext, it, expectedReceiverType) + } + + if (expectedReceiverTypeIsPresent) { + result.addElement(LookupElementBuilder.create(symbolName.toString())) + } + } else if (explicitReceiverType == null || symbol.callableId.classId == explicitReceiverType.classId) { + result.addElement(LookupElementBuilder.create(symbolName.toString())) + } } } } + private fun FirScope.collectCallableSymbols(): MutableList> { + val allCallableSymbols = mutableListOf>() + fun symbolsCollector(symbol: FirCallableSymbol<*>) { + allCallableSymbols.add(symbol) + } + + for (name in getCallableNames()) { + processFunctionsByName(name, ::symbolsCollector) + processPropertiesByName(name, ::symbolsCollector) + } + + return allCallableSymbols + } + private val Name.isConstructor get() = this == Name.special("") }