Use HintManager instead of JBPopupFactory to notify of intention failure

This commit is contained in:
Pavel V. Talanov
2014-05-22 15:44:23 +04:00
parent ca15d77f1d
commit 9ef700b081
3 changed files with 11 additions and 6 deletions
@@ -0,0 +1,5 @@
<root>
<item name='com.intellij.codeInsight.hint.HintManager com.intellij.codeInsight.hint.HintManager getInstance()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
@@ -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<JetCallExpression>("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) {
@@ -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<V: Any>(editor: Editor, maybeValue: Maybe<V, String>): V? {