Not all DynamicPluginListener methods are called
Answered
Having DynamicPluginListener
implementation as:
class CopilotDynamicPluginListener : DynamicPluginListener {
private val LOG: Logger = Logger.getInstance(CopilotDynamicPluginListener::class.java)
override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {
LOG.warn("BEFORE UNLOAD")
}
override fun checkUnloadPlugin(pluginDescriptor: IdeaPluginDescriptor) {
LOG.warn("CHECK UNLOAD")
}
override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
LOG.warn("LOADED")
}
override fun beforePluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
LOG.warn("BEFORE LOADED")
}
override fun pluginUnloaded(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {
LOG.warn("UNLOADED")
}
}
Which is registered as application listener, I see only some of them in logs:
2025-01-28 12:36:19,332 [ 39162] INFO - #c.i.i.p.DynamicPlugins - Plugins to unload: [PluginDescriptor(name=Vaadin, id=com.vaadin.intellij-plugin, descriptorPath=plugin.xml, path=~/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/intellij-plugin, version=1.0-SNAPSHOT, package=null, isBundled=false)]
2025-01-28 12:36:19,335 [ 39165] WARN - #com.vaadin.plugin.copilot.listeners.CopilotDynamicPluginListener - CHECK UNLOAD
[...]
2025-01-28 12:36:19,731 [ 39561] WARN - #com.vaadin.plugin.copilot.listeners.CopilotDynamicPluginListener - BEFORE UNLOAD
2025-01-28 12:36:19,776 [ 39606] INFO - #c.i.o.p.MergingQueueGuiExecutor - Running task: (dumb mode task) Plugin loading/unloading
[...]
2025-01-28 13:22:33,645 [2813475] INFO - #c.i.u.i.FileBasedIndexTumbler - Index rescanning has been started after `Plugin loaded/unloaded`
2025-01-28 13:22:33,645 [2813475] WARN - #com.vaadin.plugin.copilot.listeners.CopilotDynamicPluginListener - LOADED
Why other methods are not called?
I am particularly interested in beforePluginLoaded
and pluginUnloaded
events…
Using: Build #IU-243.23654.117, built on January 16, 2025
Please sign in to leave a comment.
Hi,
The
DynamicPluginListener.beforePluginLoaded()
is called here:https://github.com/JetBrains/intellij-community/blob/243/platform/platform-impl/src/com/intellij/ide/plugins/DynamicPlugins.kt#L926
It can be skipped if
return false
from line 908 is executed, or another exception occurs.It is similar with
DynamicPluginListener.pluginUnloaded()
, see https://github.com/JetBrains/intellij-community/blob/243/platform/platform-impl/src/com/intellij/ide/plugins/DynamicPlugins.kt#L599., but I don't see a return in this case.If it is reproducible, I suggest using the debugger to see what happens in your case. If you spot any issue, please report it at https://youtrack.jetbrains.com/issues/IJPL.