Search in sources :

Example 1 with ArrangementSectionRuleData

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

the class ArrangementSectionRulesControl method getSections.

public List<ArrangementSectionRule> getSections() {
    if (getModel().getSize() <= 0) {
        return Collections.emptyList();
    }
    final List<ArrangementSectionRule> result = ContainerUtil.newArrayList();
    final List<StdArrangementMatchRule> buffer = ContainerUtil.newArrayList();
    String currentSectionStart = null;
    for (int i = 0; i < getModel().getSize(); i++) {
        final Object element = getModel().getElementAt(i);
        if (element instanceof StdArrangementMatchRule) {
            final ArrangementSectionRuleData sectionRule = mySectionRuleManager == null ? null : mySectionRuleManager.getSectionRuleData((StdArrangementMatchRule) element);
            if (sectionRule != null) {
                if (sectionRule.isSectionStart()) {
                    appendBufferedSectionRules(result, buffer, currentSectionStart);
                    currentSectionStart = sectionRule.getText();
                } else {
                    result.add(ArrangementSectionRule.create(StringUtil.notNullize(currentSectionStart), sectionRule.getText(), buffer));
                    buffer.clear();
                    currentSectionStart = null;
                }
            } else {
                if (currentSectionStart == null) {
                    result.add(ArrangementSectionRule.create((StdArrangementMatchRule) element));
                } else {
                    buffer.add((StdArrangementMatchRule) element);
                }
            }
        }
    }
    appendBufferedSectionRules(result, buffer, currentSectionStart);
    return result;
}
Also used : ArrangementSectionRuleData(com.intellij.application.options.codeStyle.arrangement.match.ArrangementSectionRuleManager.ArrangementSectionRuleData) ArrangementSectionRule(com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)

Aggregations

ArrangementSectionRuleData (com.intellij.application.options.codeStyle.arrangement.match.ArrangementSectionRuleManager.ArrangementSectionRuleData)1 ArrangementSectionRule (com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule)1 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)1