Refactored ReferenceVariantsHelper to allow specifying receiver

This commit is contained in:
Valentin Kipyatkov
2015-08-26 19:19:01 +03:00
parent 6dde70e358
commit fbb37f0154
6 changed files with 60 additions and 42 deletions
@@ -328,7 +328,8 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
}
private fun Collection<CallableDescriptor>.filterShadowedNonImported(): Collection<CallableDescriptor> {
return ShadowedDeclarationsFilter(bindingContext, resolutionFacade).filterNonImported(this, referenceVariants, nameExpression!!)
val explicitReceiverData = ReferenceVariantsHelper.getExplicitReceiverData(nameExpression!!)
return ShadowedDeclarationsFilter(bindingContext, resolutionFacade, nameExpression, explicitReceiverData).filterNonImported(this, referenceVariants)
}
protected fun addAllClasses(kindFilter: (ClassKind) -> Boolean) {
@@ -90,9 +90,9 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para
// special completion for outside parenthesis lambda argument
private fun addFunctionLiteralArgumentCompletions() {
if (nameExpression != null) {
val receiverData = ReferenceVariantsHelper.getExplicitReceiverData(nameExpression)
if (receiverData != null && receiverData.second == CallType.INFIX) {
val call = receiverData.first.getCall(bindingContext)
val (receiverExpression, callType) = ReferenceVariantsHelper.getExplicitReceiverData(nameExpression) ?: return
if (callType == CallType.INFIX) {
val call = receiverExpression.getCall(bindingContext)
if (call != null && call.getFunctionLiteralArguments().isEmpty()) {
val dummyArgument = object : FunctionLiteralArgument {
override fun getFunctionLiteral() = throw UnsupportedOperationException()