Search in sources :

Example 1 with StdArrangementExtendableSettings

use of com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings in project intellij-community by JetBrains.

the class ArrangementSettingsSerializationTest method testCustomTokenSerializeAndDeserialize.

@Test
public void testCustomTokenSerializeAndDeserialize() {
    final StdArrangementRuleAliasToken visibility = visibilityToken();
    final StdArrangementRuleAliasToken modifiers = modifiersToken();
    final Set<StdArrangementRuleAliasToken> tokens = ContainerUtil.newHashSet(visibility, modifiers);
    final ArrayList<ArrangementGroupingRule> groupings = ContainerUtil.newArrayList(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrayList<ArrangementSectionRule> rules = ContainerUtil.newArrayList(section(true, FIELD, visibility));
    final StdArrangementExtendableSettings settings = extendableSettings(groupings, rules, tokens);
    final StdArrangementExtendableSettings defaultSettings = new StdArrangementExtendableSettings();
    doSerializationTest(settings, defaultSettings);
}
Also used : StdArrangementRuleAliasToken(com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken) ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) StdArrangementExtendableSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) Test(org.junit.Test)

Example 2 with StdArrangementExtendableSettings

use of com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings in project intellij-community by JetBrains.

the class ArrangementSettingsSerializationTest method testDefaultCustomTokenSerialize.

@Test
public void testDefaultCustomTokenSerialize() {
    final Set<StdArrangementRuleAliasToken> tokens = ContainerUtil.newHashSet(visibilityToken());
    final ArrayList<ArrangementGroupingRule> groupings = ContainerUtil.newArrayList(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrayList<ArrangementSectionRule> rules = ContainerUtil.newArrayList(section(true, FIELD));
    final StdArrangementExtendableSettings settings = extendableSettings(groupings, rules, tokens);
    final Element holder = doSerializationTest(settings, settings.clone());
    assertTrue(holder.getChildren().isEmpty());
}
Also used : StdArrangementRuleAliasToken(com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken) ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) StdArrangementExtendableSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings) Element(org.jdom.Element) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) Test(org.junit.Test)

Example 3 with StdArrangementExtendableSettings

use of com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings in project intellij-community by JetBrains.

the class ArrangementSettingsSerializationTest method testCustomTokenSerializeMoreThanDefault.

@Test
public void testCustomTokenSerializeMoreThanDefault() throws IOException {
    final Set<StdArrangementRuleAliasToken> tokens = ContainerUtil.newHashSet(visibilityToken(), modifiersToken());
    final ArrayList<ArrangementGroupingRule> groupings = ContainerUtil.newArrayList(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrayList<ArrangementSectionRule> rules = ContainerUtil.newArrayList(section(true, FIELD));
    final StdArrangementExtendableSettings settings = extendableSettings(groupings, rules, tokens);
    final Set<StdArrangementRuleAliasToken> defaultTokens = ContainerUtil.newHashSet(visibilityToken());
    final StdArrangementExtendableSettings defaultSettings = extendableSettings(groupings, rules, defaultTokens);
    final Element holder = doSerializationTest(settings, defaultSettings);
    final String expected = "<holder>\n" + "  <tokens>\n" + "    <token id=\"modifiers\" name=\"modifiers\">\n" + "      <rules>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PUBLIC>true</PUBLIC>\n" + "              <STATIC>true</STATIC>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PROTECTED>true</PROTECTED>\n" + "              <STATIC>true</STATIC>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PRIVATE>true</PRIVATE>\n" + "              <STATIC>true</STATIC>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PUBLIC>true</PUBLIC>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PROTECTED>true</PROTECTED>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PRIVATE>true</PRIVATE>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "      </rules>\n" + "    </token>\n" + "    <token id=\"visibility\" name=\"visibility\">\n" + "      <rules>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PUBLIC>true</PUBLIC>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PROTECTED>true</PROTECTED>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PRIVATE>true</PRIVATE>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "      </rules>\n" + "    </token>\n" + "  </tokens>\n" + "</holder>";
    assertXmlOutputEquals(expected, holder);
}
Also used : StdArrangementRuleAliasToken(com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken) ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) StdArrangementExtendableSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings) Element(org.jdom.Element) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) Test(org.junit.Test)

Example 4 with StdArrangementExtendableSettings

use of com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings in project intellij-community by JetBrains.

the class ArrangementSettingsSerializationTest method testUseCustomTokenSerialize.

@Test
public void testUseCustomTokenSerialize() throws IOException {
    final StdArrangementRuleAliasToken visibility = visibilityToken();
    final StdArrangementRuleAliasToken modifiers = modifiersToken();
    final Set<StdArrangementRuleAliasToken> tokens = ContainerUtil.newHashSet(visibility, modifiers);
    final ArrayList<ArrangementGroupingRule> groupings = ContainerUtil.newArrayList(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrayList<ArrangementSectionRule> rules = ContainerUtil.newArrayList(section(true, FIELD, visibility));
    final StdArrangementExtendableSettings settings = extendableSettings(groupings, rules, tokens);
    final ArrayList<ArrangementSectionRule> defaultRules = ContainerUtil.newArrayList(section(true, FIELD));
    final StdArrangementExtendableSettings defaultSettings = extendableSettings(groupings, defaultRules, tokens);
    final Element holder = doSerializationTest(settings, defaultSettings);
    final String expected = "<holder>\n" + "  <rules>\n" + "    <section>\n" + "      <rule>\n" + "        <match>\n" + "          <AND>\n" + "            <FIELD>true</FIELD>\n" + "            <visibility />\n" + "          </AND>\n" + "        </match>\n" + "        <order>BY_NAME</order>\n" + "      </rule>\n" + "    </section>\n" + "  </rules>\n" + "</holder>";
    assertXmlOutputEquals(expected, holder);
}
Also used : StdArrangementRuleAliasToken(com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken) ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) StdArrangementExtendableSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings) Element(org.jdom.Element) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) Test(org.junit.Test)

Example 5 with StdArrangementExtendableSettings

use of com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings in project intellij-community by JetBrains.

the class ArrangementSettingsSerializationTest method testCustomTokenSerializeLessThanDefault.

@Test
public void testCustomTokenSerializeLessThanDefault() throws IOException {
    final Set<StdArrangementRuleAliasToken> tokens = ContainerUtil.newHashSet(visibilityToken());
    final ArrayList<ArrangementGroupingRule> groupings = ContainerUtil.newArrayList(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrayList<ArrangementSectionRule> rules = ContainerUtil.newArrayList(section(true, FIELD));
    final StdArrangementExtendableSettings settings = extendableSettings(groupings, rules, tokens);
    final Set<StdArrangementRuleAliasToken> defaultTokens = ContainerUtil.newHashSet(visibilityToken(), modifiersToken());
    final StdArrangementExtendableSettings defaultSettings = extendableSettings(groupings, rules, defaultTokens);
    final Element holder = doSerializationTest(settings, defaultSettings);
    final String expected = "<holder>\n" + "  <tokens>\n" + "    <token id=\"visibility\" name=\"visibility\">\n" + "      <rules>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PUBLIC>true</PUBLIC>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PROTECTED>true</PROTECTED>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "        <rule>\n" + "          <match>\n" + "            <AND>\n" + "              <PRIVATE>true</PRIVATE>\n" + "            </AND>\n" + "          </match>\n" + "        </rule>\n" + "      </rules>\n" + "    </token>\n" + "  </tokens>\n" + "</holder>";
    assertXmlOutputEquals(expected, holder);
}
Also used : StdArrangementRuleAliasToken(com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken) ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) StdArrangementExtendableSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings) Element(org.jdom.Element) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) Test(org.junit.Test)

Aggregations

ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)5 ArrangementSectionRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule)5 StdArrangementExtendableSettings (com.intellij.psi.codeStyle.arrangement.std.StdArrangementExtendableSettings)5 StdArrangementRuleAliasToken (com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken)5 Test (org.junit.Test)5 Element (org.jdom.Element)4