Search in sources :

Example 16 with ArrangementAtomMatchCondition

use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition 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)

Example 17 with ArrangementAtomMatchCondition

use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.

the class ArrangementMatchNodeComponentFactory method getComponent.

/**
   * Allows to build UI component for the given model.
   *
   * @param rendererTarget      target model element for which UI component should be built
   * @param rule                rule which contains given 'renderer target' condition and serves as
   *                            a data entry for the target list model
   * @param allowModification   flag which indicates whether given model can be changed at future
   * @return renderer for the given model
   */
@NotNull
public ArrangementUiComponent getComponent(@NotNull final ArrangementMatchCondition rendererTarget, @NotNull final StdArrangementMatchRule rule, final boolean allowModification) {
    final Ref<ArrangementUiComponent> ref = new Ref<>();
    rendererTarget.invite(new ArrangementMatchConditionVisitor() {

        @Override
        public void visit(@NotNull ArrangementAtomMatchCondition condition) {
            RemoveAtomConditionCallback callback = allowModification ? new RemoveAtomConditionCallback(rule) : null;
            ArrangementUiComponent component = new ArrangementAtomMatchConditionComponent(mySettingsManager, myColorsProvider, condition, callback);
            ref.set(component);
        }

        @Override
        public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
            ref.set(new ArrangementAndMatchConditionComponent(rule, condition, ArrangementMatchNodeComponentFactory.this, mySettingsManager, allowModification));
        }
    });
    return ref.get();
}
Also used : ArrangementUiComponent(com.intellij.psi.codeStyle.arrangement.std.ArrangementUiComponent) Ref(com.intellij.openapi.util.Ref) ArrangementMatchConditionVisitor(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) ArrangementAtomMatchConditionComponent(com.intellij.application.options.codeStyle.arrangement.component.ArrangementAtomMatchConditionComponent) ArrangementCompositeMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition) ArrangementAndMatchConditionComponent(com.intellij.application.options.codeStyle.arrangement.component.ArrangementAndMatchConditionComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with ArrangementAtomMatchCondition

use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.

the class ArrangementSectionRuleManager method createDefaultSectionRule.

@NotNull
public StdArrangementMatchRule createDefaultSectionRule() {
    final ArrangementAtomMatchCondition type = new ArrangementAtomMatchCondition(START_SECTION);
    final ArrangementAtomMatchCondition text = new ArrangementAtomMatchCondition(TEXT, createDefaultSectionText());
    final ArrangementMatchCondition condition = ArrangementUtil.combine(type, text);
    return new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition));
}
Also used : ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) ArrangementMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with ArrangementAtomMatchCondition

use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.

the class AbstractRearrangerTest method nameRule.

@NotNull
protected static StdArrangementMatchRule nameRule(@NotNull String nameFilter, @NotNull ArrangementSettingsToken... tokens) {
    if (tokens.length == 0) {
        return new StdArrangementMatchRule(new StdArrangementEntryMatcher(atom(nameFilter)));
    } else {
        ArrangementAtomMatchCondition[] conditions = new ArrangementAtomMatchCondition[tokens.length + 1];
        conditions[0] = atom(nameFilter);
        for (int i = 0; i < tokens.length; i++) conditions[i + 1] = atom(tokens[i]);
        ArrangementMatchCondition compositeCondition = ArrangementUtil.combine(conditions);
        return new StdArrangementMatchRule(new StdArrangementEntryMatcher(compositeCondition));
    }
}
Also used : ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) ArrangementMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with ArrangementAtomMatchCondition

use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project CSSReorder by anton-rudeshko.

the class CssRearranger method addRule.

private static void addRule(String propertyName) {
    ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, propertyName);
    StdArrangementEntryMatcher matcher = new StdArrangementEntryMatcher(condition);
    StdArrangementMatchRule matchRule = new StdArrangementMatchRule(matcher, StdArrangementTokens.Order.BY_NAME);
    DEFAULT_MATCH_RULES.add(ArrangementSectionRule.create(matchRule));
}
Also used : ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) StdArrangementEntryMatcher(com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)

Aggregations

ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)31 ArrangementCompositeMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition)15 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)13 Test (org.junit.Test)13 StdArrangementEntryMatcher (com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher)11 ArrangementMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition)11 ArrangementMatchConditionVisitor (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor)9 NotNull (org.jetbrains.annotations.NotNull)9 ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)6 ArrangementSettingsToken (com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken)6 StdArrangementSettings (com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings)6 Element (org.jdom.Element)6 Nullable (org.jetbrains.annotations.Nullable)5 Ref (com.intellij.openapi.util.Ref)4 ModifierAwareArrangementEntry (com.intellij.psi.codeStyle.arrangement.ModifierAwareArrangementEntry)3 TypeAwareArrangementEntry (com.intellij.psi.codeStyle.arrangement.TypeAwareArrangementEntry)3 Expectations (org.jmock.Expectations)2 ArrangementAndMatchConditionComponent (com.intellij.application.options.codeStyle.arrangement.component.ArrangementAndMatchConditionComponent)1 ArrangementAtomMatchConditionComponent (com.intellij.application.options.codeStyle.arrangement.component.ArrangementAtomMatchConditionComponent)1 ArrangementRuleAliasDialog (com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog)1