diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/DynamicPluginVfsListener.kt b/platform/platform-impl/src/com/intellij/ide/plugins/DynamicPluginVfsListener.kt index 6d15fe402c20..51634b4b125a 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/DynamicPluginVfsListener.kt +++ b/platform/platform-impl/src/com/intellij/ide/plugins/DynamicPluginVfsListener.kt @@ -5,10 +5,12 @@ import com.intellij.ide.FrameStateListener import com.intellij.notification.NotificationType import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.PathManager +import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.vfs.AsyncFileListener import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtilCore +import com.intellij.openapi.vfs.newvfs.RefreshQueue import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent import com.intellij.openapi.vfs.newvfs.events.VFileEvent import com.intellij.util.SystemProperties @@ -19,6 +21,8 @@ import com.intellij.util.SystemProperties private const val AUTO_RELOAD_PLUGINS_SYSTEM_PROPERTY = "idea.auto.reload.plugins" class DynamicPluginVfsListener : AsyncFileListener { + private var initialRefreshDone = false + init { if (SystemProperties.`is`(AUTO_RELOAD_PLUGINS_SYSTEM_PROPERTY)) { val pluginsPath = PathManager.getPluginsPath() @@ -27,18 +31,23 @@ class DynamicPluginVfsListener : AsyncFileListener { if (pluginsRoot != null) { // ensure all plugins are in VFS VfsUtilCore.processFilesRecursively(pluginsRoot) { true } + RefreshQueue.getInstance().refresh(true, true, Runnable { initialRefreshDone = true }, pluginsRoot) } } } override fun prepareChange(events: List): AsyncFileListener.ChangeApplier? { if (!SystemProperties.`is`(AUTO_RELOAD_PLUGINS_SYSTEM_PROPERTY)) return null + if (!initialRefreshDone) return null val pluginsToReload = hashSetOf() for (event in events) { if (!event.isFromRefresh) continue if (event is VFileContentChangeEvent) { - findPluginByPath(event.path)?.let { pluginsToReload.add(it) } + findPluginByPath(event.path)?.let { + LOG.info("Detected plugin .jar file change ${event.path}, reloading plugin") + pluginsToReload.add(it) + } } } val descriptorsToReload = pluginsToReload @@ -75,6 +84,10 @@ class DynamicPluginVfsListener : AsyncFileListener { FileUtil.isAncestor(it.pluginPath.toAbsolutePath().toString(), path, false) } as IdeaPluginDescriptorImpl? } + + companion object { + val LOG = Logger.getInstance(DynamicPluginVfsListener::class.java) + } } class DynamicPluginsFrameStateListener : FrameStateListener {