From 9ef700b081a6ad3a70dfb9c35a6cfbfe6b68a1b9 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 22 May 2014 15:44:23 +0400 Subject: [PATCH] Use HintManager instead of JBPopupFactory to notify of intention failure --- annotations/com/intellij/codeInsight/hint/annotations.xml | 5 +++++ .../intentions/ReplaceWithInfixFunctionCallIntention.kt | 5 +++-- .../AttributeCallReplacementIntention.kt | 7 +++---- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 annotations/com/intellij/codeInsight/hint/annotations.xml diff --git a/annotations/com/intellij/codeInsight/hint/annotations.xml b/annotations/com/intellij/codeInsight/hint/annotations.xml new file mode 100644 index 00000000000..8f6b01d0c8f --- /dev/null +++ b/annotations/com/intellij/codeInsight/hint/annotations.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt index 54906496c0f..3e235949fb2 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt +++ b/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt @@ -22,12 +22,12 @@ import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression import org.jetbrains.jet.plugin.caches.resolve.getBindingContext import org.jetbrains.jet.lang.resolve.BindingContext import org.jetbrains.jet.plugin.JetBundle -import com.intellij.openapi.ui.popup.JBPopupFactory import org.jetbrains.jet.lang.psi.JetValueArgument import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache import org.jetbrains.jet.lang.types.PackageType import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils import org.jetbrains.jet.lang.psi.JetPsiFactory +import com.intellij.codeInsight.hint.HintManager public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntention("replace.with.infix.function.call.intention", javaClass()) { override fun isApplicableTo(element: JetCallExpression): Boolean { @@ -78,7 +78,8 @@ public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntent } open fun intentionFailed(editor: Editor, messageID: String) { - JBPopupFactory.getInstance()!!.createMessage("Intention failed: ${JetBundle.message("replace.with.infix.function.call.intention.error.$messageID")}").showInBestPositionFor(editor) + val message = "Intention failed: ${JetBundle.message("replace.with.infix.function.call.intention.error.$messageID")}" + HintManager.getInstance().showErrorHint(editor, message) } override fun applyTo(element: JetCallExpression, editor: Editor) { diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt index 16e5f0d7779..b79da247d09 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt @@ -21,7 +21,6 @@ import com.intellij.openapi.editor.Editor import org.jetbrains.jet.lang.psi.JetQualifiedExpression import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression import org.jetbrains.jet.plugin.intentions.JetSelfTargetingIntention -import com.intellij.openapi.ui.popup.JBPopupFactory import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache import org.jetbrains.jet.lang.descriptors.CallableDescriptor @@ -33,6 +32,7 @@ import org.jetbrains.jet.lang.resolve.calls.model.VarargValueArgument import org.jetbrains.jet.plugin.util.Maybe import org.jetbrains.jet.plugin.util.MaybeError import org.jetbrains.jet.plugin.util.MaybeValue +import com.intellij.codeInsight.hint.HintManager // Internal because you shouldn't construct this manually. You can end up with an inconsistant CallDescription. public class CallDescription internal ( @@ -121,9 +121,8 @@ public abstract class AttributeCallReplacementIntention(name: String) : JetSelfT } protected open fun intentionFailed(editor: Editor, messageId: String, vararg values: Any?) { - JBPopupFactory.getInstance()!! - .createMessage("Intention Failed: ${JetBundle.message("replace.call.error.${messageId}", *values)}") - .showInBestPositionFor(editor) + val message = "Intention failed: ${JetBundle.message("replace.call.error.${messageId}", *values)}" + HintManager.getInstance().showErrorHint(editor, message) } protected fun handleErrors(editor: Editor, maybeValue: Maybe): V? {