About
A file must be associated to a file type.
Articles Related
Steps
File Type
public class SimpleFileType extends LanguageFileType {
public static final SimpleFileType INSTANCE = new SimpleFileType();
private SimpleFileType() {
super(SimpleLanguage.INSTANCE);
}
@NotNull
@Override
public String getName() {
return "Simple file";
}
@NotNull
@Override
public String getDescription() {
return "Simple language file";
}
@NotNull
@Override
public String getDefaultExtension() {
return "simple";
}
@Nullable
@Override
public Icon getIcon() {
return SimpleIcon.FILE;
}
}
Factory
public class SimpleFileTypeFactory extends FileTypeFactory {
@Override
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
fileTypeConsumer.consume(SimpleFileType.INSTANCE, "simple");
}
}
Registration
In plugin.xml, via platform extension
<idea-plugin version="2">
<!-- ....... -->
<extensions defaultExtensionNs="com.intellij">
<fileTypeFactory implementation="com.gerardnico.SimpleFileTypeFactory"/>
</extensions>
</idea-plugin>
Test
Run the project, create a file with the same extension and verify that this the good Icon