Is it possible to associate file type automatically if it is already associated?
Answered
Hi. I am creating plugin for *.eo files. Most users have already associated *.eo files as txt long time ago. My plugin doesn't work for these people because plugin doesn't see .eo files. It is possible to fix it manually if you go to preferences and remove association *.eo with *.txt. Then plugin starts highlight code and etc.
But is it possible to remove eo to txt association programatically? May be there are other solutions? Hope my question is clear
Please sign in to leave a comment.
Hi Stepa,
It is possible by implementing com.intellij.psi.LanguageSubstitutor and registering in com.intellij.lang.substitutor EP.
Couldn't find clear documentation. Should it look like this?
Here I tried to associate *.eo files with EO languages and this code is reachable but it doesn't work
If you already associated *.eo with text files and after that installed my plugin still occurs this problem
I expected to see *.eo in right tab (even if *.eo are already associated with text files)
1. I mean that EOLanguage.INSTANCE returned
2. Implementation FileType
FileTypeFactory:
Registration:
3. EO files opened but associated with text. It means that user has done this before downloading my plugin:
By the way, I tried to reproduce this problem (IntelliJ 2020.3.2). I associated *.eo with text and then installed my plugin) I got message:
But my colleges with other versions don't receive this message and *.eo files are still associated with text
What is the reason for using fileTypeFactory? It is deprecated. Could you please switch to fileType as the deprecation comment suggests and see if the problem is solved?
I upgraded org.jetbrains.intellij to 1.2.0 and removed fileTypeFactory but problem still appears.
Source: https://github.com/yasamprom/eo-intellij-plugin-copy2
Please try with FileTypeManager, e.g.
Could you please provide more examples or link to documentation? I tried to add this code in PluginContoller class into projectOpened method but I don't see my logs in idea.logs
Why isn't this code reachable?
Well, I found this solution:
I inserted this code into initComponent in PluginController class