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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations