Simplify logic in ReplaceWithInfixFunctionCallIntention

This commit is contained in:
Pavel V. Talanov
2014-05-22 15:40:39 +04:00
parent 3334857870
commit ca15d77f1d
@@ -25,7 +25,6 @@ import org.jetbrains.jet.plugin.JetBundle
import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.ui.popup.JBPopupFactory
import org.jetbrains.jet.lang.psi.JetValueArgument import org.jetbrains.jet.lang.psi.JetValueArgument
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
import org.jetbrains.jet.analyzer.computeTypeInfoInContext
import org.jetbrains.jet.lang.types.PackageType import org.jetbrains.jet.lang.types.PackageType
import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils
import org.jetbrains.jet.lang.psi.JetPsiFactory import org.jetbrains.jet.lang.psi.JetPsiFactory
@@ -91,20 +90,16 @@ public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntent
val valueArguments = element.getValueArgumentList()?.getArguments() ?: listOf<JetValueArgument>() val valueArguments = element.getValueArgumentList()?.getArguments() ?: listOf<JetValueArgument>()
val functionLiteralArguments = element.getFunctionLiteralArguments() val functionLiteralArguments = element.getFunctionLiteralArguments()
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(parent) val bindingContext = AnalyzerFacadeWithCache.getContextForElement(parent)
val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, parent] val receiverType = bindingContext[BindingContext.EXPRESSION_TYPE, receiver]
when { when {
scope == null -> { receiverType == null -> {
intentionFailed(editor, "resolution.failed") intentionFailed(editor, "resolution.failed")
return return
} }
else -> receiverType is PackageType -> {
when (receiver.computeTypeInfoInContext(scope).getType()) { intentionFailed(editor, "package.call")
is PackageType -> { return
intentionFailed(editor, "package.call") }
return
}
}
} }
rightHandTextStringBuilder.append( rightHandTextStringBuilder.append(