I tried to import Google's Java code style with IntelliJ.
The style file contains the following configuration:
<code_scheme name="GoogleStyle">
<option name="JAVA_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
...
</value>
</option>
...
</code_scheme>
But after the import my settings still show
Tab size 4 (instead of 8)
Indent 4 (instead of 2)
Continuation indent 8 (instead of 4)
When I export that style scheme then in the output file the values are the same as in the original file:
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
Steps I took to import the style:
I'm using IntelliJ IDEA Community 2016.2.2
The expected result is that when I import the style then created style scheme has indent size (etc) the same as specified in the code scheme file.
How can I do that?
EDITED The file from Google uses an old (I suppose) key for filetype (java instead of Java). I have made the following changes and it works.
<ADDITIONAL_INDENT_OPTIONS fileType="JAVA">
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</ADDITIONAL_INDENT_OPTIONS>
I have made a fork of the GitHub repository with the file corrected ( https://github.com/nhenneaux/styleguide/blob/gh-pages/intellij-java-google-style.xml ).
The easiest way is to import the style file into ~/.IntelliJIdea2016.2/config/codestyles
. Then you have to restart Intellij and go in the style settings to select GoogleStyle.
It seems that the format used in the configuration file differes from what IntelliJ (at least the version I'm using) expects.
I changed my code setting, exported them and looked for differences.
The ident setting were in the output file like so:
<code_scheme name="MyTestStyle">
...
<codeStyleSettings language="JAVA">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
Importing this file worked as expected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.