Search in sources :

Example 6 with ArrangementSettingsToken

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

the class ArrangementGroupingRulesControl method setRules.

public void setRules(@Nullable List<ArrangementGroupingRule> rules) {
    for (ArrangementGroupingComponent component : myComponents.values()) {
        component.setSelected(false);
    }
    if (rules == null) {
        return;
    }
    DefaultTableModel model = getModel();
    while (model.getRowCount() > 0) {
        model.removeRow(model.getRowCount() - 1);
    }
    final Set<ArrangementSettingsToken> groupingTokens = ContainerUtilRt.newHashSet(myComponents.keySet());
    for (ArrangementGroupingRule rule : rules) {
        final ArrangementSettingsToken groupingType = rule.getGroupingType();
        ArrangementGroupingComponent component = myComponents.get(groupingType);
        component.setSelected(true);
        component.setOrderType(rule.getOrderType());
        model.addRow(new Object[] { component });
        groupingTokens.remove(groupingType);
    }
    List<ArrangementSettingsToken> types = ContainerUtilRt.newArrayList(groupingTokens);
    types = mySettingsManager.sort(types);
    for (ArrangementSettingsToken type : types) {
        model.addRow(new Object[] { myComponents.get(type) });
    }
}
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)

Example 7 with ArrangementSettingsToken

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

the class ActionScriptRearranger method getDefaultMatchRules.

public static List<StdArrangementMatchRule> getDefaultMatchRules() {
    // more or less close to Coding Conventions at http://sourceforge.net/adobe/flexsdk/wiki/Coding%20Conventions/
    final List<StdArrangementMatchRule> matchRules = new ArrayList<>();
    final Set<ArrangementSettingsToken> visibility = VISIBILITY_MODIFIERS;
    // static initialization blocks
    addRule(matchRules, STATIC_INIT);
    // constants
    addRule(matchRules, CONST);
    // static vars
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, VAR, modifier, STATIC);
    }
    // static properties
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, PROPERTY, modifier, STATIC);
    }
    // static methods
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, METHOD, modifier, STATIC);
    }
    // constructor
    addRule(matchRules, CONSTRUCTOR);
    // vars
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, VAR, modifier);
    }
    // properties
    addRule(matchRules, PROPERTY, OVERRIDE);
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, PROPERTY, modifier);
    }
    // methods
    addRule(matchRules, METHOD, OVERRIDE);
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, METHOD, modifier);
    }
    // event handlers
    addRule(matchRules, EVENT_HANDLER, OVERRIDE);
    for (ArrangementSettingsToken modifier : visibility) {
        addRule(matchRules, EVENT_HANDLER, modifier);
    }
    return matchRules;
}
Also used : ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)

Example 8 with ArrangementSettingsToken

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

the class ActionScriptRearranger method detectModifiers.

@NotNull
protected Set<ArrangementSettingsToken> detectModifiers(@NotNull final JSAttributeListOwner fieldOrMethod) {
    final Set<ArrangementSettingsToken> result = ContainerUtil.newHashSet();
    final JSAttributeList attributes = fieldOrMethod.getAttributeList();
    if (attributes != null) {
        JSAttributeList.AccessType accessType = attributes.getExplicitAccessType();
        if (accessType == null) {
            final String namespace = attributes.getNamespace();
            if (namespace == null) {
                accessType = JSAttributeList.AccessType.PACKAGE_LOCAL;
            }
        }
        if (accessType != null) {
            switch(accessType) {
                case PUBLIC:
                    result.add(PUBLIC);
                    break;
                case PROTECTED:
                    result.add(PROTECTED);
                    break;
                case PACKAGE_LOCAL:
                    result.add(PACKAGE_PRIVATE);
                    break;
                case PRIVATE:
                    result.add(PRIVATE);
                    break;
            }
        }
        if (attributes.hasModifier(JSAttributeList.ModifierType.STATIC))
            result.add(STATIC);
        if (attributes.hasModifier(JSAttributeList.ModifierType.FINAL))
            result.add(FINAL);
        if (attributes.hasModifier(JSAttributeList.ModifierType.OVERRIDE))
            result.add(OVERRIDE);
    }
    return result;
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with ArrangementSettingsToken

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

the class JavaArrangementVisitor method visitMethod.

@Override
public void visitMethod(PsiMethod method) {
    boolean isSectionCommentsDetected = registerSectionComments(method);
    final TextRange range = isSectionCommentsDetected ? getElementRangeWithoutComments(method) : method.getTextRange();
    ArrangementSettingsToken type = method.isConstructor() ? CONSTRUCTOR : METHOD;
    JavaElementArrangementEntry entry = createNewEntry(method, range, type, method.getName(), true);
    if (entry == null) {
        return;
    }
    processEntry(entry, method, method.getBody());
    parseProperties(method, entry);
    myInfo.onMethodEntryCreated(method, entry);
    MethodSignatureBackedByPsiMethod overridden = SuperMethodsSearch.search(method, null, true, false).findFirst();
    if (overridden != null) {
        entry.addModifier(OVERRIDDEN);
        myInfo.onOverriddenMethod(overridden.getMethod(), method);
    }
    boolean reset = myMethodBodyProcessor.setBaseMethod(method);
    try {
        method.accept(myMethodBodyProcessor);
    } finally {
        if (reset) {
            myMethodBodyProcessor.setBaseMethod(null);
        }
    }
}
Also used : MethodSignatureBackedByPsiMethod(com.intellij.psi.util.MethodSignatureBackedByPsiMethod) ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) TextRange(com.intellij.openapi.util.TextRange)

Example 10 with ArrangementSettingsToken

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

the class JavaArrangementVisitor method visitClass.

@Override
public void visitClass(PsiClass aClass) {
    boolean isSectionCommentsDetected = registerSectionComments(aClass);
    TextRange range = isSectionCommentsDetected ? getElementRangeWithoutComments(aClass) : aClass.getTextRange();
    ArrangementSettingsToken type = CLASS;
    if (aClass.isEnum()) {
        type = ENUM;
    } else if (aClass.isInterface()) {
        type = INTERFACE;
    }
    JavaElementArrangementEntry entry = createNewEntry(aClass, range, type, aClass.getName(), true);
    processEntry(entry, aClass, aClass);
}
Also used : ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) TextRange(com.intellij.openapi.util.TextRange)

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