Codestyle xml
Hi,
I'd like to deliver a codestyle together with my plugin. Is there any kind of api to implement that behaviour from my plugin?
The only thing I've found is
http://navinpeiris.com/2011/09/11/sharing-exportimport-intellij-idea-code-style-formatters/
However, this only refers to manually copying over the required file.
Thanks,
Matthias
请先登录再写评论。
You can do this programatically via com.intellij.psi.codeStyle.PredefinedCodeStyle
Hi Yann,
thanks for your answer. I suppose I can change code style settings only programmatically, can't I? There is no option to import your nice codestyle xml files?
Edit: Just found #readExternal. I'll give that one a try.
Thanks,
Matthias
Hi,
I tried out the predefinedCodestyle approach. This won't deliver a codestyle.xml, but only make the codestyle available as a kind of template (copy from option). This is not what I want - I want to import a complete codestyle file. For now I ended up using the "idea.config.path" system property to find out the codestyles folder and copy the style into the folder. The copying is now implemented as ApplicationComponent.
Matthias
Currently there is no API for built-in code styles and this is done intentionally because a code style scheme contains settings for multiple languages and if some sort of a bundled scheme would be chosen, it would also change code styles for other languages (likely to default ones). Usually this is not what a user wants. Instead he expects other settings he has already defined to be left untouched and apply only the ones from a predefined scheme to a specifc language without changing other languages' settings and even some for this very language.
Though if you want to allow to import some settings manually, you can do this by implementing SchemeImporter<CodeStyleScheme> interface.
Hi,
ok,this makes sense.
One more question: the system property idea.config.path should contain the configuration directory of IntelliJ. Starting idea from plugin dev, the system property is set. Starting IntelliJ from a Windows machine using the idea64 binary, the system property is not set. How can I obtain the configuration directory in those cases?
Matthias
I guess you can get it from PathManager.getConfigPath()
Perfect, thanks!