Search in sources :

Example 16 with ArrangementCompositeMatchCondition

use of com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition 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());
}
Also used : Ref(com.intellij.openapi.util.Ref) ArrangementMatchConditionVisitor(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor) ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) CompositeArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.CompositeArrangementSettingsToken) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) ArrangementCompositeMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition) ArrangementMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ArrangementCompositeMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition)16 ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)15 ArrangementMatchConditionVisitor (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor)9 ArrangementMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition)8 NotNull (org.jetbrains.annotations.NotNull)6 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)5 Ref (com.intellij.openapi.util.Ref)4 Nullable (org.jetbrains.annotations.Nullable)4 Test (org.junit.Test)4 StdArrangementEntryMatcher (com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher)3 ArrangementSettingsToken (com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken)3 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 ModifierAwareArrangementEntry (com.intellij.psi.codeStyle.arrangement.ModifierAwareArrangementEntry)1 TypeAwareArrangementEntry (com.intellij.psi.codeStyle.arrangement.TypeAwareArrangementEntry)1 ArrangementSectionRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule)1 ArrangementUiComponent (com.intellij.psi.codeStyle.arrangement.std.ArrangementUiComponent)1 CompositeArrangementSettingsToken (com.intellij.psi.codeStyle.arrangement.std.CompositeArrangementSettingsToken)1 THashSet (gnu.trove.THashSet)1