Extensions
Extensions are the most common way for a plugin to extend the IntelliJ-based IDE's functionality. They are implementations of specific interfaces or classes that are registered in the plugin descriptor. Provided extension implementations are called by the platform or other plugins to customize and extend the IDE's functionality.
Common Extension Use Cases
The following are some of the most common tasks achieved using extensions:
The
com.intellij.toolWindowextension point allows plugins to add tool windows (panels displayed at the sides of the IDE user interface);The
com.intellij.applicationConfigurableextension point andcom.intellij.projectConfigurableextension point allow plugins to add pages to the Settings dialog;Custom language plugins use many extension points to extend various language support features in the IDE.
There are more than 1700 extension points available in the platform and the bundled plugins, allowing customizing different parts of the IDE behavior.
Exploring Available Extensions
Documentation
IntelliJ Community Plugins Extension Point and Listener List (bundled plugins in IntelliJ IDEA)
Lists for other IDEs are available under Product Specific (for example, PhpStorm).
IntelliJ Platform Explorer
Browse usages inside existing implementations of open-source IntelliJ Platform plugins via IntelliJ Platform Explorer.
Code Insight
Alternatively (or when using 3rd party extension points), all available extension points for the specified namespace (defaultExtensionNs) can be listed using auto-completion inside the <extensions> block in plugin.xml. Use in the lookup list to access more information about the extension point and implementation (if applicable).
See Explore the IntelliJ Platform API for more information and strategies.
Declaring Extensions
Declaring Extension
Add an
<extensions>element to plugin.xml if it's not yet present there. Set thedefaultExtensionNsattribute to one of the following values:com.intellijif the plugin extends the IntelliJ Platform core functionality.{ID of a plugin}if the plugin extends the functionality of another plugin (must configure plugin dependencies).
Add a new child element to the
<extensions>element. The child element's name must match the name of the used extension point.Depending on the type of the extension point, do one of the following:
If the extension point was declared using the
interfaceattribute, set theimplementationattribute to the name of the class that implements the specified interface.If the extension point was declared using the
beanClassattribute, set all properties annotated with the@AttributeandTagannotations in the specified bean class.
See the Declaring Extension Point section for details.
In addition to attributes defined by the extension point, the extension element can specify basic attributes (see the attributes list in An Extension section).
Implement the extension API as required (see Implementing Extension).
To clarify this procedure, consider the following sample section of the plugin.xml file that defines two extensions designed to access the com.intellij.appStarter and com.intellij.projectTemplatesFactory extension points in the IntelliJ Platform, and one extension to access the another.plugin.myExtensionPoint extension point in another plugin another.plugin:
Implementing Extension
Please note the following important points:
Extension implementation must be stateless. Use explicit services for managing (runtime) data.
Avoid any initialization in the constructor, see also notes for services.
Do not perform any static initialization. Use inspection Plugin DevKit | Code | Static initialization in extension point implementations (2023.3).
An extension implementation must not be registered as a service additionally. Use inspection Plugin DevKit | Code | Extension registered as service/component (2023.3).
If an extension instance needs to "opt out" in certain scenarios, it can throw
ExtensionNotApplicableExceptionin its constructor.
When using Kotlin:
Do not use
objectbutclassfor implementation. More detailsDo not use
companion objectto avoid excessive classloading/initialization when the extension class is loaded. Use top-level declarations or objects instead. More details
Extension Properties Code Insight
Several tooling features are available to help configure bean class extension points in plugin.xml.
Required Properties
Properties annotated with RequiredElement are inserted automatically and validated.
If the given property is allowed to have an explicit empty value, set allowEmpty to true.
Class names
Property names matching the following list will resolve to a fully qualified class name:
implementationclassNameending with
Class(case-sensitive)serviceInterface/serviceImplementation
A required parent type can be specified in the extension point declaration via <with>:
Custom resolve
Property name language (or ending in *Language) resolves to all present Language IDs.
Similarly, action and actionId (2024.3+) resolve to all registered <action> IDs.
Deprecation/ApiStatus
Properties marked as @Deprecated or annotated with any of ApiStatus @Internal, @Experimental, @ScheduledForRemoval, or @Obsolete will be highlighted accordingly.
Enum properties
Enum attributes support code insight with lowerCamelCased notation. Note: The Enum implementation must not override toString().
I18n
Annotating with @Nls validates a UI String capitalization according to the text property Capitalization enum value.