Registering a File Type
The first step in developing a custom language plugin is registering a file type associated with the language.
The IDE typically determines the type of a file by looking at its filename or extension.
A custom language file type is a class derived from LanguageFileType
, which passes a Language
subclass to its base class constructor.
Registration
When targeting 2019.2 or later only, use com.intellij.fileType
extension point to register LanguageFileType
implementation and instance via implementationClass
and fieldName
attributes. Also, name
and language
must be declared matching FileType.getName()
and ID of language returned from LanguageFileType.getLanguage()
, respectively.
To associate the file type in the IDE, specify one or more associations as listed in the following table.
Association type | Attribute | Attribute value |
---|---|---|
Filename extension(s) |
| Semicolon-separated list of extensions, without |
Hard coded file name(s) |
| Semicolon-separated list of exact (case-insensitive) file names |
Filename pattern(s) |
| Semicolon-separated list of patterns ( |
Hashbang (2020.2+) |
| Semicolon-separated list of hash bang patterns |
To register a file type, the plugin developer provides a subclass of FileTypeFactory
, which is registered via the com.intellij.fileTypeFactory
extension point.
Examples
LanguageFileType
subclass in Properties language plugin
To verify that the file type is registered correctly, you can implement the LanguageFileType.getIcon()
method and verify that the correct icon (see Working with Icons and Images) is displayed for files associated with your file type.
Additional Features
If you want IDEs to show a hint prompting users that your plugin supports a specific file type, see Plugin Recommendations.
To control file type association with the IDE in the operating system, implement OSFileIdeAssociation
(2020.3).