By defining extension points in your plugin, you can allow other plugins to extend your plugin's functionality. There are two types of extension points:
Interface extension points allow other plugins to extend your plugins with code. When you define an interface extension point, you specify an interface, and other plugins will provide classes implementing that interface. You'll then be able to invoke methods on those interfaces.
Bean extension points allow other plugins to extend your plugins with data. You specify the fully qualified name of an extension class, and other plugins will provide data that will be turned into instances of that class.
Declaring Extension Points
You can declare extensions and extension points in the plugin configuration file plugin.xml, within the
To declare extension points in your plugin, add an
<extensionPoints> section to your plugin.xml. Then insert a child element
<extensionPoint> that defines the extension point name and the name of a bean class or an interface that is allowed to extend the plugin functionality in the
interface attributes, respectively.
name attribute assigns a unique name for this extension point. Its fully qualified name required in Using Extension Points is built by prefixing
beanClass attribute sets a bean class that specifies one or several properties annotated with the
@Attribute annotation. Note that bean classes do not follow the JavaBean standard.
interface attribute sets an interface the plugin that contributes to the extension point must implement.
area attribute determines the scope in which the extension will be instantiated. As extensions should be stateless, it is not recommended to use non-default. Must be one of
IDEA_APPLICATION for Application (default),
IDEA_PROJECT for Project, or
IDEA_MODULE for Module scope.
The plugin that contributes to the extension point will read those properties from the plugin.xml file.
To clarify this, consider the following sample
MyBeanClass bean class used in the above plugin.xml file:
For above extension points usage in anotherPlugin would look like this (see also Declaring Extensions):
Using Extension Points
A gutter icon for the
ExtensionPointName declaration allows navigating to the corresponding
<extensionPoint> declaration in plugin.xml.
Dynamic Extension Points
To support Dynamic Plugins (2020.1 and later), an extension point must adhere to specific usage rules:
extensions are enumerated on every use and extensions instances are not stored anywhere
ExtensionPointListenercan perform necessary updates of data structures (register via
Extension points matching these conditions can then be marked as dynamic by adding
dynamic="true" in their declaration: