Trying to create a Kotlin Intention

Answered

Inside my intention I want to create some code that is valid Kotlin but not valid Java.

override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
val factory = JavaPsiFacade.getInstance(project).elementFactory
val softly = factory.createReferenceFromText("ablock { }", null)
element.replace(softly)
}

I'm guessing I need some kind of Kotlin factory but I can't figure out how to get one.

2 comments
Comment actions Permalink

See org.jetbrains.kotlin.psi.KtPsiFactory

0

Please sign in to leave a comment.