IntelliJ Platform Plugin SDK Help

2. Language and File Type

The IntelliJ Platform determines file type by examining the name of a file. Each language has Language and LanguageFileType objects defining the language. Register the LanguageFileType with the IntelliJ Platform in the plugin configuration file.

Define the Language

The language implemented in this tutorial is named "Simple" - note the case of the name. The SimpleLanguage class is defined in the org.intellij.sdk.language package of the simple_language_plugin code sample:

Define an Icon

The icon for the Simple Language is defined by the SimpleIcons class. Please see Working with Icons and Images for details on how to define and use icons.

Define a FileType

The SimpleFileType is defined by subclassing LanguageFileType:

Register the FileType

The Simple Language file type is registered via the com.intellij.fileType extension point in plugin.xml and registered with *.simple extension:

<extensions defaultExtensionNs="com.intellij"> <fileType name="Simple File" implementationClass="org.intellij.sdk.language.SimpleFileType" fieldName="INSTANCE" language="Simple" extensions="simple"/> </extensions>

Define a FileType Factory

First, define SimpleFileTypeFactory as a subclass of FileTypeFactory.

Register the FileType Factory

The SimpleFileTypeFactory is registered using the com.intellij.fileTypeFactory extension point in plugin.xml.

<extensions defaultExtensionNs="com.intellij"> <fileTypeFactory implementation="org.intellij.sdk.language.SimpleFileTypeFactory"/> </extensions>
Last modified: 29 九月 2022