idea-plugin / arrow.meta.ide.dsl.editor.intention / IntentionSyntax / addIntention


open fun MetaIde.addIntention(intention: IntentionAction): ExtensionPhase

registers intention

open fun <K : KtElement> MetaIde.addIntention(text: String = "", kClass: Class<K> = as Class<K>, isApplicableTo: (element: K, caretOffset: Int) -> Boolean = Noop.boolean2False, applyTo: KtPsiFactory.(element: K, editor: Editor) -> Unit = Noop.effect3, priority: Priority = PriorityAction.Priority.LOW): ExtensionPhase

This extension registers an SelfTargetingIntention. The following example renames a helloWorld function to renamed, whenever the user decides to trigger that Intention.

import arrow.meta.ide.IdePlugin
import arrow.meta.ide.MetaIde
import arrow.meta.ide.invoke
// import com.intellij.codeInsight.intention.PriorityAction
import org.jetbrains.kotlin.psi.KtNamedFunction
import com.intellij.openapi.editor.Editor

val MetaIde.example: IdePlugin
 get() = "SampleIntention"{
    text = "Rename HelloWorld Function",
    isApplicableTo = { f: KtNamedFunction, caretOffset: Int -> == "helloWorld"
    kClass =,
    applyTo = { f: KtNamedFunction, editor: Editor ->

IntentionAction are generally on-demand computations, similar to AnAction, unless they’re composed with other workflows, which trigger them, automatically.

See Also


Do you like Arrow?

Arrow Org