Plugin Components are a legacy feature supported for compatibility with plugins created for older versions of the IntelliJ Platform. Plugins using Components do not support dynamic loading (the ability to install, update, and uninstall plugins without restarting the IDE).
Plugin Components are defined in the
<module-components> sections in a Plugin Configuration File.
To migrate existing code from Components to more modern APIs, please see the following guidelines.
To manage some state or logic that is only needed when the user performs a specific operation, use a Service.
Subscribing to Events
Executing code on application startup should be avoided whenever possible because it slows down startup. Plugin code should only be executed when projects are opened (see Project Open) or when the user invokes an action of a plugin. If this cannot be avoided, add a listener subscribing to the
To execute an activity in background on IDE startup (e.g., to warm up caches), use
To execute code when a project is being opened, use one of these two extensions:
StartupActivityfor immediate execution on EDT. Implement
DumbAwareto indicate activity can run in background thread (in parallel with other such tasks).
StartupActivity.Backgroundfor execution with 5 seconds delay in background thread (2019.3 or later).
Any long-running or CPU intensive tasks should be made visible to users by using
ProgressManager.run(Task.Backgroundable). Access to indices must be wrapped with
DumbService, see also General Threading Rules.
To execute code on project closing or application shutdown, implement the
Disposable interface in a Service and place the code in the
dispose() method. Alternatively, use
Disposer.register() passing a
Application service instance as the
parent argument (see Choosing a Disposable Parent).