Multiple file patterns
Hey there,
for my custom language plugin I need more than one registeres file extension (t1, t2, t3).
I put the extensions in an array and override the getDefaultExtension() method:
@NonNls
public static final String[] DEFAULT_EXTENSIONS = {"t1", "t2", "t3"};
@NotNull @NonNls public String getDefaultExtension() { return DEFAULT_EXTENSIONS[0]; }
In file MyLanguageFileTypeFactory I pull the extensions inside a for loop from the array and pass it to the consume() method of FileTypeConsumer
@Override public void createFileTypes(@NotNull FileTypeConsumer consumer) { for (int i = 0; i < MyLanguageFileType.DEFAULT_EXTENSIONS.length; i++) { consumer.consume(MyLanguageFileType.FILE_TYPE, MyLanguageFileType.DEFAULT_EXTENSIONS[i]); } }
When I debug the plugin inside PHPStorm all three extension patterns will registered. But if I create a jar file of the plugin and install it regulary in an normal instance of PHPStorm only the last one extension is found (t3). If I pass just one extension to consume() no extension is registered:
consumer.consume(MyLanguageFileType.FILE_TYPE, "t1");
What did I wrong?
Regards
Stefano
请先登录再写评论。
The FileTypeConsumer.consume() method actually accepts a string of multiple file name patterns separated by semicolons.
Yeah I know and it doesn't work for me. Even if I call consume() just with one extension no extension pattern is registered in PHPStorm.
To clarify:
In instance of PHPStorm which starts up if I press the Run / Debug button inside IDEA there will all file extensions registered.
But if I export the plugin via Build->Prepare Module "MyModule" for deployment and install it in my regular PHPStorm installation it work as described above.
Stefano
Please make sure your plugin is loaded at all. http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
I put this <depends>com.intellij.modules.lang</depends> to plugin.xml.
I create a new plugin for testing with just one file extension but it won't be registered in PHPStorm when I install the jar file by the plugin manager.
There are MyLangFileType.java, MyLangFileTypeFactory.java, MyLangLanguage.java and MyLangBundle.java files and as I mentioned above I put
<depends>com.intellij.modules.lang</depends> and <fileTypeFactory implementation="org.stefano.myLang.fileTypes.TypoScriptFileTypeFactory"/> to plugin.xml.
I don't get where the problem is. Maybe someone of you guys will be able to enlighten me.
Regards
Stefano
Hey,
I fix the issue by myself. The problem was that I had associated the fileextensions for my filetype already with the normal text filetype.
After remove the connection, they will associated with my custom language.
Stefano
I know this is resurrecting an old thread but how do I dis-associate a filetype?
Update: Found it under Preferences - Editor - File Types
Then Text and remove the extension