Code Style Scheme questions

已回答

I accidentally have 2 Code Style Schemes.  I want to compare the two, merge them into one, and then get rid of the extra one.

I was doing this by exporting both to XML file, diffing the XMLs, then looking in Preferences > Editor > Code Style to see the effects of the settings that are different between the two schemes.

Is this the most efficient way to achieve this?

I have a few questions about the XMLs:

1. How do I modify the following XML elements from the preferences dialog?

<option name="HTML_ATTRIBUTE_WRAP" value="4" />
<option name="HTML_ALIGN_ATTRIBUTES" value="false" />
<option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="" />

Those are different between the 2 XMLs, but all settings under Preferences > Editor > Code Style > HTML look the same to me.

2. How do I modify <JetCodeStyleSettings> from the preferences dialog?  What plugin adds support for that element?

3. How do I modify <ECMA4CodeStyleSettings> from the preferences dialog?  What plugin adds support for that element?

4. Each SQL code style settings elements has a version attribute, e.g. <MySQLCodeStyleSettings version="0">.  In one XML, they are all set to 0, in the other, they're all set to 1.  I used the preferences dialog to set the values as the same for one of the database types, but one file still has version 0 and the other still has 1.  They also have different values in some child elements.  What do these versions mean?  How do I make them the same in both code style schemes?

5. I see both <codeStyleSettings language="HAML"> & <codeStyleSettings language="Haml">.  I'm able to modify the latter from the preferences dialog.  the two XMLs have differences under the former element.  What plugin or other tool adds the former to the preferences dialog?  If the former is vestigial, and should be removed, how can I remove it from the existing schemes?  If I can't do that, can I export the schemes as XML, delete the schemes, delete the vestigial elements from the XMLs, then import the XMLs?

Thanks.

0

><option name="HTML_ATTRIBUTE_WRAP" value="4" />

It should correspond to Settings (Preferences on macOS) | Editor | Code Style | HTML | Other | Wrap attributes:

><option name="HTML_ALIGN_ATTRIBUTES" value="false" />

Settings (Preferences on macOS) | Editor | Code Style | HTML | Other | Align attributes

><option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="" />

Settings (Preferences on macOS) | Editor | Code Style | HTML | Other | Do not indent children of:

>2. How do I modify <JetCodeStyleSettings> from the preferences dialog? What plugin adds support for that element?

Looks like it comes from AndroidStudio or Kotlin-related plugin.

>3. How do I modify <ECMA4CodeStyleSettings> from the preferences dialog? What plugin adds support for that element?

Looks like it is https://github.com/JetBrains/intellij-plugins/tree/master/flex

>4. Each SQL code style settings elements has a version attribute, e.g. <MySQLCodeStyleSettings version="0">. In one XML, they are all set to 0, in the other, they're all set to 1. I used the preferences dialog to set the values as the same for one of the database types, but one file still has version 0 and the other still has 1. They also have different values in some child elements. What do these versions mean? How do I make them the same in both code style schemes?

These are compatibility versions. You should not change them manually (as any other values in these xml files).

>5. I see both <codeStyleSettings language="HAML"> & <codeStyleSettings language="Haml">. I'm able to modify the latter from the preferences dialog. the two XMLs have differences under the former element. What plugin or other tool adds the former to the preferences dialog? If the former is vestigial, and should be removed, how can I remove it from the existing schemes? If I can't do that, can I export the schemes as XML, delete the schemes, delete the vestigial elements from the XMLs, then import the XMLs?

These code style settings come from Haml bundled plugin.

You can try removing not needed elements, just make sure that the xml file stays a valid xml.

0

Thanks for the info.

 

I think the 3 options that begin with HTML_ ar vestigial, since I think that they are now covered under <HTMLCodeStyleSettings>, e.g.,:

<HTMLCodeStyleSettings>
    <option name="HTML_ATTRIBUTE_WRAP" value="4" />
    <option name="HTML_ALIGN_ATTRIBUTES" value="false" />
</HTMLCodeStyleSettings>

Is that correct?  If so, how do I remove the vestigial settings?

Is the Flex plugin in the plugin repository?

I know that language="Haml" is from the Haml plugin, but language="HAML" doesn't seem to be modified by that.  Is the latter vestigial?

0

>I think the 3 options that begin with HTML_ ar vestigial, since I think that they are now covered under <HTMLCodeStyleSettings>, e.g.,:

Not really sure what you mean here. In any case it is not recommended to edit xml configuration files manually. If you really need/want you can edit them manually but note that it can lead to some unexpected behavior.

0

My XML file looks like:

<code_scheme name="<name>" version="173">
    …
    <option name="HTML_ATTRIBUTE_WRAP" value="4" />
    <option name="HTML_ALIGN_ATTRIBUTES" value="false" />
    <option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="" />
    …
    <HTMLCodeStyleSettings>
        <option name="HTML_ATTRIBUTE_WRAP" value="4" />
        <option name="HTML_ALIGN_ATTRIBUTES" value="false" />
    </HTMLCodeStyleSettings>

</code_scheme>

I think that in older versions of IntelliJ, the settings above were stored in <option>s that are direct children of <code_scheme>.

I think that in newer versions of IntelliJ, the settings are now stored in <option>s that are direct children of <HTMLCodeStyleSettings>, which itself is a child of <code_scheme>.

I think that, for some reason, the <option>s that are direct children of <code_scheme> are still sitting in my settings file, but should have been deleted in some IntelliJ upgrade.  I think that they are no longer read from, and  can no longer be updated or deleted.

Is that correct?

0

Similarly, I think that the following elements:

<code_scheme name="<name>" version="173">
    …
    <option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
    <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
    <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
    <option name="IMPORT_LAYOUT_TABLE">
      <value>
        <package name="" withSubpackages="true" static="false" />
        <emptyLine />
        <package name="" withSubpackages="true" static="true" />
      </value>
    </option>
    …
</code_scheme>

Have been moved from <code_scheme> into <code_scheme>/<JavaCodeStyleSettings>.

Is that correct?

0

Are the following <codeStyleSettings>s obsolete?

<code_scheme name="example" version="173">
    <codeStyleSettings language="HAML">…</codeStyleSettings>
</code_scheme>

 

Are the following code style <option>s obsolete? (I've omitted values to make them more readable)

<code_scheme name="example" version="173">
    <option name="OTHER_INDENT_OPTIONS">
        <value>
            <option name="CONTINUATION_INDENT_SIZE" />
        </value>
    </option>
    <option name="INSERT_INNER_CLASS_IMPORTS" />
    <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" />
    <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" />
    <option name="IMPORT_LAYOUT_TABLE">
        <value>
            <package name="" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="" withSubpackages="true" static="true" />
        </value>
    </option>
    <option name="HTML_ATTRIBUTE_WRAP" />
    <option name="HTML_ALIGN_ATTRIBUTES" />
    <option name="HTML_DO_NOT_INDENT_CHILDREN_OF" />
    <(*AnyDatabase*)CodeStyleSettings>
        <option name="myVersion" />
        <option name="PRIMARY_KEY_NAME_TEMPLATE" />
    </(*AnyDatabase*)CodeStyleSettings>
    <(H2|HSQL|MySQL|SQLite)CodeStyleSettings>
        <option name="IMP_DECLARE_EL_WRAP" />
        <option name="IMP_IF_THEN_WRAP_THEN" />
    </(H2|HSQL|MySQL|SQLite)CodeStyleSettings>
    <SqlCodeStyleSettings>
        <option name="SUBQUERY_L_PAR_NL_INSIDE" />
        <option name="NEW_LINE_BEFORE_JOIN_CONDITION" />
        <option name="NEW_LINE_BEFORE_QUERY_INSIDE_PARENTHESIS" />
        <option name="NEW_LINE_BEFORE_QUERY_INSIDE_DML" />
        <option name="INDENT_JOIN" />
        <option name="INDENT_JOIN_CONDITION" />
        <option name="WRAP_INSIDE_SELECT" />
        <option name="WRAP_INSIDE_JOIN_EXPRESSION" />
        <option name="WRAP_INSIDE_GROUP_BY" />
        <option name="WRAP_INSIDE_WHERE" />
        <option name="WRAP_INSIDE_ORDER_BY" />
        <option name="WRAP_INSIDE_SET" />
        <option name="WRAP_INSIDE_ARGUMENT_DEFINITION" />
        <option name="NEW_LINE_AFTER_SELECT_2" />
    </SqlCodeStyleSettings>
    <XML>
        <option name="XML_LEGACY_SETTINGS_IMPORTED" />
    </XML>
</code_scheme>

0

I've asked responsible developer to comment on this.

0

Thanks.

My previous post sums up all of my remaining questions (except the one later in this post), so the developer can just read & answer that, and ignore my earlier posts.

One additional question:

What is the purpose of version="<some-version>" in <(.*C|c)odeStyleSettings> elements?

0

Here is the reply:

You can't manipulate the code style directly without a risk to break the way the IDE works.
Anyway, version="173" applies to all IDE versions starting from 2017.3, it's not obsolete.


I think version="version" in <...codeStyleSettings> is currently used only for SQL languages. Possibly because DataGrip team has decided to rework their settings at some point. Perhaps it's better to ask them of what settings have changed and at which point.

0

I wasn't asking about version="173", I was asking about all the specific <option>s listed in my question, like:

<SqlCodeStyleSettings>
        <option name="SUBQUERY_L_PAR_NL_INSIDE" />
</SqlCodeStyleSettings>

i.e. is an <option> with name="SUBQUERY_L_PAR_NL_INSIDE" inside a <SqlCodeStyleSettings> no longer used for anything?

Same question for all the specific <option>s listed above.

There seems to be 2 categories of <option>s that seem to be obsolete to me:

1. some <option>s were previously directly under <code_scheme>, but were later moved into various <...codeStyleSettings>, so the originals are now obsolete.

2. some <option>s are just no longer used

0

We do not track compatibility table for different specific code style options. The options may change over the IDE versions. That is why it is not recommended to change them manually in xml files.

0

请先登录再写评论。