jenkinsci / idea-stapler-plugin

Jenkins Development Support for IntelliJ IDEA
https://plugins.jetbrains.com/plugin/1885-jenkins-development-support/
BSD 2-Clause "Simplified" License
9 stars 20 forks source link

Enable plugin loading/unloading without restart #60

Open duemir opened 3 years ago

duemir commented 3 years ago

Dependencies

Blocked on IntellIJ upstream bug: https://youtrack.jetbrains.com/issue/IDEA-263300

Feature Request

According to https://plugins.jetbrains.com/plugin/1885-stapler-framework-support/versions following is what is blocking it:

Plugin Stapler Framework Support 2.0.0 cannot be enabled nor disabled without IDE restart because the following requirements are not satisfied: Plugin cannot be loaded/unloaded without IDE restart because it declares non-dynamic extensions: com.intellij.fileTypeFactory

duemir commented 3 years ago

It requires a newer IntelliJ baseline. com.intellij.fileTypeFactory was deprecated in 2019.2.

duemir commented 2 years ago

Registering a File Type | IntelliJ Platform Plugin SDK

jgreffe commented 2 years ago

Hello @duemir ,

with last master, I tried following this: https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#restrictions

But IDEA states nothing to report (?) Monosnap hacktoberfest – plugin xml (Stapler plugin for IntelliJ IDEA) 2022-11-02 09-21-48

And running locally:

$ gradle runPluginVerifier -PideaVersion=2022.2.3
...
Plugin Stapler plugin for IntelliJ IDEA:2.1.0 against IC-222.4345.14: Compatible
    Plugin can probably be enabled or disabled without IDE restart

Plugin Stapler plugin for IntelliJ IDEA:2.1.0 against IC-223.6160.11: Compatible
    Plugin can probably be enabled or disabled without IDE restart
...

But it seems it's still not dynamic, as when installed, trying to uninstall -> requires IDE restart :/

duemir commented 2 years ago

Check https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#code

Do not store references to PSI elements in objects which can survive plugin loading or unloading; use SmartPsiElementPointer instead.

A bunch of XmlTag-s and XmlAttributes are stored around directly, I believe. Something to look into as far as this feature goes.

duemir commented 2 years ago

I don't know how much of a clue it is, but when I updated the plugin in IntelliJ Community Edition, dynamic reload worked.

jgreffe commented 2 years ago

I'm my side, can't make it reload dynamically :/ In a terminal:

$ gradle runIde -PrunIde.jvmArgs+="-XX:+UnlockDiagnosticVMOptions" -PideaVersion=2022.1

In the opened sandbox:

In another terminal:

$ gradle buildPlugin -xbuildSearchableOptions

Switch focus back to sandbox:

2022-11-07 08:41:28,213 [ 44808] INFO - #c.i.i.p.DynamicPlugins - Plugin Stapler plugin for IntelliJ IDEA is not unload-safe because class loader cannot be unloaded. Memory snapshot created at /Users/xxx/unload-Stapler plugin for IntelliJ IDEA-07.11.2022_08.41.21.hprof

duemir commented 2 years ago

That looks like the new PSI class that you introduced, which appears to be used as a key in the map somewhere inside IntelliJ. Other than asking in Jetbrains Slack and reporting to their YouTrack if that's what they suggest on Slack, I have no ideas.

To be honest this is nice to have category in my head, so I personally would not be spending much time on this.

jgreffe commented 2 years ago

Same issue with standard simple language demo from JetBrains. Created https://youtrack.jetbrains.com/issue/IDEA-305958/simplelanguageplugin-not-dynamic

jgreffe commented 1 year ago

Created issue is a duplicate of https://youtrack.jetbrains.com/issue/IDEA-263300 (unresolved yet)