How to register PsiFile's filetype?
Answered
I want use the customer editor open my file , and i defined FileEditor,FileEditorProvider,Language,LanguageFileType , and register in plugin.xml.
When i open the file , the virtualfile's file type is my defined language, but the psifile's file type is plaintext.
My language class
public class EntityLanguage extends Language {
public static final EntityLanguage INSTANCE = new EntityLanguage();
protected EntityLanguage() {
super("Entity","application/entity", "text/entity");
}
}
plugin.xml extension
<fileType
name="Entity File"
implementationClass="com.zewei.nebula.nds.lang.EntityLanguageFileType"
fieldName="INSTANCE"
language="Entity"
extensions="entity"/>
Please sign in to leave a comment.
Hi,
Please provide more details about the actual behavior. I don't understand what you mean by "virtualfiles's type is my defined language".
Virtual Files represent binary content and don't know anything about "language" concepts.
Sorry, My question is wrong.
The idea show default TextEditor and CusomerEditor like this when i open custom file .
How to show the EntityEditor only ? Thank you .
I see now.
Does your custom editor implement any additional features or is just a standard textual editor? If there are no additional features like visual editing, preview, etc. then you don't need it at all.
Try to remove it and check if your entity files are open in the standard text editor and language features do work.
My custom editor is visual editing , and I don't want user to edit content by text code .
Please try to return FileEditorPolicy.HIDE_DEFAULT_EDITOR from FileEditorProvider.getPolicy().
PS
Please provide all details like this the next time, it will speed up the issue recognition and answering the question.
Thank you for your help.
And i would provide most details on next time .