Search in sources :

Example 1 with StdArrangementSettings

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

the class ArrangementSettingsSerializationTest method testEmptyGroupings.

@Test
public void testEmptyGroupings() throws Exception {
    final StdArrangementSettings settings = new StdArrangementSettings();
    final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
    settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
    final StdArrangementSettings defaultSettings = new StdArrangementSettings();
    defaultSettings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final Element holder = doSerializationTest(settings, defaultSettings);
    assertTrue(holder.getChildren().size() == 2);
    final Element groups = holder.getChild("groups");
    assertNotNull(groups);
    assertTrue(groups.getChildren().isEmpty());
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) Element(org.jdom.Element) StdArrangementSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) Test(org.junit.Test)

Example 2 with StdArrangementSettings

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

the class ArrangementSettingsSerializationTest method all.

@Test
public void all() {
    final StdArrangementSettings settings = new StdArrangementSettings();
    settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
    settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
    doSerializationTest(settings, new StdArrangementSettings());
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) StdArrangementSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) Test(org.junit.Test)

Example 3 with StdArrangementSettings

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

the class ArrangementSettingsSerializationTest method testSectionSerialize.

@Test
public void testSectionSerialize() {
    final ArrayList<ArrangementSectionRule> sections = ContainerUtil.newArrayList(section("start section", "end section", rule(true, METHOD, PRIVATE), rule(false, METHOD, PUBLIC)), section("start section", "end section", rule(true, FIELD)));
    final StdArrangementSettings settings = settings(ContainerUtil.newArrayList(group(OVERRIDDEN_METHODS)), sections);
    final Element holder = doSerializationTest(settings, emptySettings());
    assertTrue(holder.getChildren().size() == 2);
    assertNotNull(holder.getChild("groups"));
    final Element rules = holder.getChild("rules");
    assertNotNull(rules);
    assertTrue(rules.getChildren().size() == 2);
    final Element section = rules.getChild("section");
    assertEquals(section.getAttribute("start_comment").getValue(), "start section");
    assertEquals(section.getAttribute("end_comment").getValue(), "end section");
}
Also used : Element(org.jdom.Element) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) StdArrangementSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings) Test(org.junit.Test)

Example 4 with StdArrangementSettings

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

the class ArrangementSettingsSerializationTest method testDefaultRulesFilter.

@Test
public void testDefaultRulesFilter() {
    final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME);
    final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
    final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);
    final StdArrangementSettings settings = new StdArrangementSettings();
    settings.addGrouping(groupingRule);
    settings.addRule(rule);
    final StdArrangementSettings defaultSettings = new StdArrangementSettings();
    defaultSettings.addRule(rule);
    final Element holder = doSerializationTest(settings, defaultSettings);
    assertTrue(holder.getChildren().size() == 1);
    assertNotNull(holder.getChild("groups"));
    assertNull(holder.getChild("rules"));
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) Element(org.jdom.Element) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) StdArrangementSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) Test(org.junit.Test)

Example 5 with StdArrangementSettings

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

the class ArrangementSettingsSerializationTest method testDefaultFilter.

@Test
public void testDefaultFilter() {
    final StdArrangementSettings settings = new StdArrangementSettings();
    settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
    final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
    settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
    final Element holder = doSerializationTest(settings, settings);
    assertTrue(holder.getChildren().isEmpty());
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) Element(org.jdom.Element) StdArrangementSettings(com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) Test(org.junit.Test)

Aggregations

StdArrangementSettings (com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings)9 Element (org.jdom.Element)8 Test (org.junit.Test)8 ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)6 StdArrangementEntryMatcher (com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher)6 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)6 ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)6 ArrangementSectionRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule)1