Lateinit property is not initialized when plugin starts in 2023.1 IDEA version
已回答
I wrote a plugin Git Branch Manager and it works correctly till 2023.1 version. After migrate to this version the exception occurs. During migration I've updated only versions, there are no changes in plugin code:
plugins {
id("org.jetbrains.intellij") version "1.13.3"
id("org.jetbrains.kotlin.jvm") version "1.8.21"
}
intellij {
version.set("2023.1")
}
Also plugin defined branchComboBox in a dialog file:
<component id="abf06" class="javax.swing.JComboBox" binding="branchComboBox">
and in kotlin:
class CheckoutBranchDialog(private val project: Project) : DialogWrapper(project) {
private lateinit var branchComboBox: JComboBox<String>
}
When test plugin and run(using run gradle task) it from Community edition it works as expected but when load jar file with plugin to Enterprise version it throws:
kotlin.UninitializedPropertyAccessException: lateinit property branchComboBox has not been initialized
at app.gui.CheckoutBranchDialog.initBranchComboBox(CheckoutBranchDialog.kt:61)
What could be wrong?
请先登录再写评论。
You cannot use UI Designer with bound form written in Kotlin https://youtrack.jetbrains.com/issue/KTIJ-791.
Please switch to UI DSL https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl-version-2.html or use Java.
interesting question, if I have not misunderstand , UI designer can not apply on Kotlin ? ( with XML style defination)
but I notice the code ‘https://github.com/vsigler/remote-log-console’
it use Kotlin + UI desginer (XML file ) create the toolWindow
It is wrong and not supported.
I was updating a plugin of my own and ran into this issue.
It's all well and good to say “You cannot use UI Designer with bound form written in Kotlin https://youtrack.jetbrains.com/issue/KTIJ-791.”, and even give a link to “https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl-version-2.html”, but is there anything that describes how to migrate a project that used to work just fine using UI Designer to UI DSL?
You'll need to manually re-implement your UI in Kotlin UI DSL, there is no automatic/step-by-step migration steps.