Search in sources :

Example 21 with StdArrangementMatchRule

use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.

the class StdArrangementExtendableSettings method getRuleSequence.

@Nullable
private List<StdArrangementMatchRule> getRuleSequence(@NotNull final StdArrangementMatchRule rule, @NotNull final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition) {
    final List<StdArrangementMatchRule> seqRule = ContainerUtil.newSmartList();
    rule.getMatcher().getCondition().invite(new ArrangementMatchConditionVisitor() {

        @Override
        public void visit(@NotNull ArrangementAtomMatchCondition condition) {
            final StdArrangementRuleAliasToken token = tokenIdToDefinition.get(condition.getType().getId());
            if (token != null && !token.getDefinitionRules().isEmpty()) {
                seqRule.addAll(token.getDefinitionRules());
            }
        }

        @Override
        public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
            for (ArrangementMatchCondition operand : condition.getOperands()) {
                if (!seqRule.isEmpty()) {
                    return;
                }
                operand.invite(this);
            }
        }
    });
    return seqRule;
}
Also used : ArrangementMatchConditionVisitor(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) ArrangementCompositeMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) ArrangementMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition) Nullable(org.jetbrains.annotations.Nullable)

Example 22 with StdArrangementMatchRule

use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule 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

StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)22 StdArrangementEntryMatcher (com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher)13 ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)13 ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)7 ArrangementMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition)6 StdArrangementSettings (com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings)6 Test (org.junit.Test)6 ArrangementCompositeMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition)5 Element (org.jdom.Element)5 ArrangementSectionRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule)3 NotNull (org.jetbrains.annotations.NotNull)3 ArrangementMatchConditionVisitor (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor)2 ArrangementSettingsToken (com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken)2 ArrayList (java.util.ArrayList)2 ArrangementSectionRuleData (com.intellij.application.options.codeStyle.arrangement.match.ArrangementSectionRuleManager.ArrangementSectionRuleData)1 ArrangementRuleAliasDialog (com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 ArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule)1 XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)1 THashMap (gnu.trove.THashMap)1