Search in sources :

Example 11 with ArrangementSettingsToken

use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-community by JetBrains.

the class ArrangementGroupingRulesControl method getRules.

@NotNull
public List<ArrangementGroupingRule> getRules() {
    List<ArrangementGroupingRule> result = new ArrayList<>();
    DefaultTableModel model = getModel();
    for (int i = 0, max = model.getRowCount(); i < max; i++) {
        ArrangementGroupingComponent component = (ArrangementGroupingComponent) model.getValueAt(i, 0);
        if (!component.isSelected()) {
            continue;
        }
        ArrangementSettingsToken orderType = component.getOrderType();
        if (orderType == null) {
            result.add(new ArrangementGroupingRule(component.getGroupingType()));
        } else {
            result.add(new ArrangementGroupingRule(component.getGroupingType(), orderType));
        }
    }
    return result;
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) CompositeArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.CompositeArrangementSettingsToken) ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) DefaultTableModel(javax.swing.table.DefaultTableModel) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ArrangementSettingsToken

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

Example 13 with ArrangementSettingsToken

use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-plugins by JetBrains.

the class ActionScriptRearranger method getBlankLines.

@Override
public int getBlankLines(@NotNull CodeStyleSettings settings, @Nullable JSArrangementEntry parent, @Nullable JSArrangementEntry previous, @NotNull JSArrangementEntry target) {
    if (previous == null) {
        return -1;
    }
    final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaScriptSupportLoader.ECMA_SCRIPT_L4);
    ArrangementSettingsToken type = target.getType();
    if (VAR.equals(type) || CONST.equals(type)) {
        return commonSettings.BLANK_LINES_AROUND_FIELD;
    } else if (STATIC_INIT.equals(type) || CONSTRUCTOR.equals(type) || METHOD.equals(type) || PROPERTY.equals(type) || EVENT_HANDLER.equals(type)) {
        return commonSettings.BLANK_LINES_AROUND_METHOD;
    } else {
        return -1;
    }
}
Also used : ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Aggregations

ArrangementSettingsToken (com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken)13 ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)6 ArrangementCompositeMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition)3 CompositeArrangementSettingsToken (com.intellij.psi.codeStyle.arrangement.std.CompositeArrangementSettingsToken)3 TextRange (com.intellij.openapi.util.TextRange)2 ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)2 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)2 ArrayList (java.util.ArrayList)2 DefaultTableModel (javax.swing.table.DefaultTableModel)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 JSAttributeList (com.intellij.lang.javascript.psi.ecmal4.JSAttributeList)1 Ref (com.intellij.openapi.util.Ref)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 ModifierAwareArrangementEntry (com.intellij.psi.codeStyle.arrangement.ModifierAwareArrangementEntry)1 TypeAwareArrangementEntry (com.intellij.psi.codeStyle.arrangement.TypeAwareArrangementEntry)1 StdArrangementEntryMatcher (com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher)1 ArrangementMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition)1 ArrangementMatchConditionVisitor (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor)1 MethodSignatureBackedByPsiMethod (com.intellij.psi.util.MethodSignatureBackedByPsiMethod)1