use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class DefaultArrangementEntryMatcherSerializerTest method simpleMatchers.
@Test
public void simpleMatchers() {
doTest(new ArrangementAtomMatchCondition(CLASS));
doTest(new ArrangementAtomMatchCondition(PRIVATE));
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class DefaultArrangementEntryMatcherSerializerTest method compositeConditionWithName.
@Test
public void compositeConditionWithName() {
ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition();
condition.addOperand(new ArrangementAtomMatchCondition(METHOD));
condition.addOperand(new ArrangementAtomMatchCondition(SYNCHRONIZED));
condition.addOperand(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 compositeAndCondition.
@Test
public void compositeAndCondition() {
ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition();
condition.addOperand(new ArrangementAtomMatchCondition(FIELD));
condition.addOperand(new ArrangementAtomMatchCondition(PUBLIC));
StdArrangementEntryMatcher matcher = new StdArrangementEntryMatcher(condition);
assertEquals(condition, matcher.getCondition());
final TypeAwareArrangementEntry fieldEntry = myMockery.mock(TypeAwareArrangementEntry.class, "field");
final ModifierAwareArrangementEntry publicEntry = myMockery.mock(ModifierAwareArrangementEntry.class, "public");
final TypeAndModifierAware privateFieldEntry = myMockery.mock(TypeAndModifierAware.class, "private field");
final TypeAndModifierAware publicMethodEntry = myMockery.mock(TypeAndModifierAware.class, "public method");
final TypeAndModifierAware publicFieldEntry = myMockery.mock(TypeAndModifierAware.class, "public field");
final TypeAndModifierAware publicStaticFieldEntry = myMockery.mock(TypeAndModifierAware.class, "public static field");
myMockery.checking(new Expectations() {
{
allowing(fieldEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(FIELD)));
allowing(publicEntry).getModifiers();
will(returnValue(ContainerUtilRt.newHashSet(PUBLIC)));
allowing(privateFieldEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(FIELD)));
allowing(privateFieldEntry).getModifiers();
will(returnValue(ContainerUtilRt.newHashSet(PRIVATE)));
allowing(publicMethodEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(METHOD)));
allowing(publicMethodEntry).getModifiers();
will(returnValue(ContainerUtilRt.newHashSet(PUBLIC)));
allowing(publicFieldEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(FIELD)));
allowing(publicFieldEntry).getModifiers();
will(returnValue(ContainerUtilRt.newHashSet(PUBLIC)));
allowing(publicStaticFieldEntry).getTypes();
will(returnValue(ContainerUtilRt.newHashSet(FIELD)));
allowing(publicStaticFieldEntry).getModifiers();
will(returnValue(ContainerUtilRt.newHashSet(PUBLIC, STATIC)));
}
});
assertFalse(matcher.isMatched(fieldEntry));
assertFalse(matcher.isMatched(publicEntry));
assertFalse(matcher.isMatched(privateFieldEntry));
assertFalse(matcher.isMatched(publicMethodEntry));
assertTrue(matcher.isMatched(publicFieldEntry));
assertTrue(matcher.isMatched(publicStaticFieldEntry));
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class ArrangementSectionRuleManager method getSectionRuleData.
@Nullable
public ArrangementSectionRuleData getSectionRuleData(@NotNull ArrangementMatchCondition condition) {
final Ref<Boolean> isStart = new Ref<>();
final Ref<String> text = new Ref<>();
condition.invite(new ArrangementMatchConditionVisitor() {
@Override
public void visit(@NotNull ArrangementAtomMatchCondition condition) {
final ArrangementSettingsToken type = condition.getType();
if (type.equals(START_SECTION)) {
isStart.set(true);
} else if (type.equals(END_SECTION)) {
isStart.set(false);
} else if (type.equals(TEXT)) {
text.set(condition.getValue().toString());
}
}
@Override
public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
for (ArrangementMatchCondition c : condition.getOperands()) {
c.invite(this);
if (!text.isNull() && !isStart.isNull()) {
return;
}
}
}
});
if (isStart.isNull()) {
return null;
}
return new ArrangementSectionRuleData(processSectionText(StringUtil.notNullize(text.get())), isStart.get());
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class ArrangementSettingsSerializationTest method testDefaultGroupingFilter.
@Test
public void testDefaultGroupingFilter() {
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.addGrouping(groupingRule);
final Element holder = doSerializationTest(settings, defaultSettings);
assertTrue(holder.getChildren().size() == 1);
assertNull(holder.getChild("groups"));
assertNotNull(holder.getChild("rules"));
}
Aggregations