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 for details on how to define and use icons.
Define a File Type
The SimpleFileType
is defined by subclassing LanguageFileType
:
Register the File Type
The Simple Language file type is registered via the com.intellij.fileType
extension point in plugin.xml and registered with *.simple extension:
Run the Project
Run the plugin by using the Gradle runIde
task.
Create an empty file with the extension .simple, and IntelliJ IDEA automatically associates it with our language. Note the appearance of the Simple Language file icon next to the test.simple file in the Project Tool Window, and the editor tab for the file.