Skip to content

Commit

Permalink
fix: Use DynamicPluginListener to create and remove .copilot-plugin (#…
Browse files Browse the repository at this point in the history
…299)

* Use DynamicPluginListener to create and remove .copilot-plugin

* spotless
  • Loading branch information
MarcinVaadin authored Feb 3, 2025
1 parent 400c2c3 commit fc8dc9f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.vaadin.plugin.copilot.listeners

import com.intellij.ide.plugins.DynamicPluginListener
import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.vaadin.plugin.copilot.CopilotPluginUtil

class CopilotDynamicPluginListener(private val project: Project) : DynamicPluginListener {

private val LOG: Logger = Logger.getInstance(CopilotDynamicPluginListener::class.java)

override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {
CopilotPluginUtil.removeDotFile(project)
LOG.debug("Plugin is going to be unloaded, .copilot-plugin removed")
}

override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
CopilotPluginUtil.saveDotFile(project)
LOG.debug("Plugin loaded, .copilot-plugin created")
}
}
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<listener
class="com.vaadin.plugin.listeners.ConfigurationCheckVaadinProjectListener"
topic="com.vaadin.plugin.listeners.VaadinProjectListener" />
<listener
class="com.vaadin.plugin.copilot.listeners.CopilotDynamicPluginListener"
topic="com.intellij.ide.plugins.DynamicPluginListener"/>
</projectListeners>

</idea-plugin>

0 comments on commit fc8dc9f

Please sign in to comment.