You can do this programatically via com.intellij.psi.codeStyle.PredefinedCodeStyle

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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

0

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.

0
Avatar
Permanently deleted user

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

0

I guess you can get it from PathManager.getConfigPath()

0
Avatar
Permanently deleted user

Perfect, thanks!

0

请先登录再写评论。