Search in sources :

Example 1 with ArrangementRuleAliasDialog

use of com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog in project intellij-community by JetBrains.

the class ArrangementSectionRulesControl method createRuleAliasEditDialog.

@NotNull
public ArrangementRuleAliasDialog createRuleAliasEditDialog() {
    final Set<String> tokenIds = new THashSet<>();
    final List<ArrangementSectionRule> sections = getSections();
    for (ArrangementSectionRule section : sections) {
        for (StdArrangementMatchRule rule : section.getMatchRules()) {
            rule.getMatcher().getCondition().invite(new ArrangementMatchConditionVisitor() {

                @Override
                public void visit(@NotNull ArrangementAtomMatchCondition condition) {
                    if (ArrangementUtil.isAliasedCondition(condition)) {
                        tokenIds.add(condition.getType().getId());
                    }
                }

                @Override
                public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
                    for (ArrangementMatchCondition operand : condition.getOperands()) {
                        operand.invite(this);
                    }
                }
            });
        }
    }
    final Collection<StdArrangementRuleAliasToken> aliases = getRulesAliases();
    assert aliases != null;
    return new ArrangementRuleAliasDialog(null, mySettingsManager, myColorsProvider, aliases, tokenIds);
}
Also used : ArrangementMatchConditionVisitor(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) ArrangementRuleAliasDialog(com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog) ArrangementCompositeMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition) THashSet(gnu.trove.THashSet) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule) ArrangementMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ArrangementRuleAliasDialog

use of com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog in project intellij-community by JetBrains.

the class EditRuleAliasesDefinitionAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    ArrangementSectionRulesControl control = ArrangementSectionRulesControl.KEY.getData(e.getDataContext());
    if (control == null || control.getRulesAliases() == null) {
        return;
    }
    control.hideEditor();
    final ArrangementRuleAliasDialog dialog = control.createRuleAliasEditDialog();
    if (dialog.showAndGet() && dialog.isModified()) {
        control.setRulesAliases(dialog.getRuleAliases());
    }
}
Also used : ArrangementRuleAliasDialog(com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog) ArrangementSectionRulesControl(com.intellij.application.options.codeStyle.arrangement.match.ArrangementSectionRulesControl)

Aggregations

ArrangementRuleAliasDialog (com.intellij.application.options.codeStyle.arrangement.match.tokens.ArrangementRuleAliasDialog)2 ArrangementSectionRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementSectionRulesControl)1 ArrangementSectionRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule)1 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)1 ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)1 ArrangementCompositeMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition)1 ArrangementMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition)1 ArrangementMatchConditionVisitor (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor)1 THashSet (gnu.trove.THashSet)1 NotNull (org.jetbrains.annotations.NotNull)1