use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition 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());
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class DefaultArrangementEntryMatcherSerializerTest method compositeMatchers.
@Test
public void compositeMatchers() {
ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition();
condition.addOperand(new ArrangementAtomMatchCondition(METHOD));
condition.addOperand(new ArrangementAtomMatchCondition(SYNCHRONIZED));
doTest(condition);
condition = new ArrangementCompositeMatchCondition();
condition.addOperand(new ArrangementAtomMatchCondition(FIELD));
condition.addOperand(new ArrangementAtomMatchCondition(PUBLIC));
condition.addOperand(new ArrangementAtomMatchCondition(STATIC));
condition.addOperand(new ArrangementAtomMatchCondition(FINAL));
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class DefaultArrangementEntryMatcherSerializerTest method conditionsOrder.
@Test
public void conditionsOrder() {
// Inspired by IDEA-91826.
ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition();
ArrangementSettingsToken typeToPreserve = FIELD;
Set<ArrangementSettingsToken> modifiersToPreserve = ContainerUtilRt.newHashSet(PUBLIC, STATIC, FINAL);
condition.addOperand(new ArrangementAtomMatchCondition(typeToPreserve, typeToPreserve));
for (ArrangementSettingsToken modifier : modifiersToPreserve) {
condition.addOperand(new ArrangementAtomMatchCondition(modifier, modifier));
}
Element element = mySerializer.serialize(new StdArrangementEntryMatcher(condition));
assertNotNull(element);
// Change hash-container data distribution at the composite condition.
for (ArrangementSettingsToken type : StdArrangementTokens.EntryType.values()) {
if (type != typeToPreserve) {
condition.addOperand(new ArrangementAtomMatchCondition(type, type));
}
}
for (ArrangementSettingsToken modifier : StdArrangementTokens.Modifier.values()) {
if (!modifiersToPreserve.contains(modifier)) {
condition.addOperand(new ArrangementAtomMatchCondition(modifier, modifier));
}
}
// Revert state to the initial one.
for (ArrangementSettingsToken type : StdArrangementTokens.EntryType.values()) {
if (type != typeToPreserve) {
condition.removeOperand(new ArrangementAtomMatchCondition(type, type));
}
}
for (ArrangementSettingsToken modifier : StdArrangementTokens.Modifier.values()) {
if (!modifiersToPreserve.contains(modifier)) {
condition.removeOperand(new ArrangementAtomMatchCondition(modifier, modifier));
}
}
// Check that the order is the same
Element actual = mySerializer.serialize(new StdArrangementEntryMatcher(condition));
assertNotNull(actual);
checkElements(element, actual);
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class DefaultArrangementEntryMatcherSerializerTest method nameConditionOnly.
@Test
public void nameConditionOnly() {
ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, "get*");
doTest(condition);
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class StandardArrangementEntryMatcherTest method atomCondition.
@Test
public void atomCondition() {
ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
StdArrangementEntryMatcher matcher = new StdArrangementEntryMatcher(condition);
assertEquals(condition, matcher.getCondition());
final TypeAwareArrangementEntry fieldEntry = myMockery.mock(TypeAwareArrangementEntry.class, "field");
final TypeAwareArrangementEntry classEntry = myMockery.mock(TypeAwareArrangementEntry.class, "class");
final ModifierAwareArrangementEntry publicEntry = myMockery.mock(ModifierAwareArrangementEntry.class, "public");
myMockery.checking(new Expectations() {
{
allowing(fieldEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(FIELD)));
allowing(classEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(CLASS)));
allowing(publicEntry).getModifiers();
will(returnValue(ContainerUtilRt.newHashSet(PUBLIC)));
}
});
assertTrue(matcher.isMatched(fieldEntry));
assertFalse(matcher.isMatched(classEntry));
assertFalse(matcher.isMatched(publicEntry));
}
Aggregations