use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class AbstractRearrangerTest method nameRule.
@NotNull
protected static StdArrangementMatchRule nameRule(@NotNull String nameFilter, @NotNull ArrangementSettingsToken... tokens) {
if (tokens.length == 0) {
return new StdArrangementMatchRule(new StdArrangementEntryMatcher(atom(nameFilter)));
} else {
ArrangementAtomMatchCondition[] conditions = new ArrangementAtomMatchCondition[tokens.length + 1];
conditions[0] = atom(nameFilter);
for (int i = 0; i < tokens.length; i++) conditions[i + 1] = atom(tokens[i]);
ArrangementMatchCondition compositeCondition = ArrangementUtil.combine(conditions);
return new StdArrangementMatchRule(new StdArrangementEntryMatcher(compositeCondition));
}
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule 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;
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class StdArrangementExtendableSettings method appendExpandedRules.
public void appendExpandedRules(@NotNull final StdArrangementMatchRule rule, @NotNull final List<StdArrangementMatchRule> rules, @NotNull final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition) {
final List<StdArrangementMatchRule> sequence = getRuleSequence(rule, tokenIdToDefinition);
if (sequence == null || sequence.isEmpty()) {
rules.add(rule);
return;
}
final ArrangementCompositeMatchCondition ruleTemplate = removeAliasRuleToken(rule.getMatcher().getCondition());
for (StdArrangementMatchRule matchRule : sequence) {
final ArrangementCompositeMatchCondition extendedRule = ruleTemplate.clone();
extendedRule.addOperand(matchRule.getMatcher().getCondition());
rules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(extendedRule)));
}
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class StdArrangementExtendableSettings method getExtendedSectionRules.
@Override
public List<ArrangementSectionRule> getExtendedSectionRules() {
synchronized (myExtendedSectionRules) {
if (myExtendedSectionRules.isEmpty()) {
final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition = new THashMap<>(myRulesAliases.size());
for (StdArrangementRuleAliasToken alias : myRulesAliases) {
final String id = alias.getId();
tokenIdToDefinition.put(id, alias);
}
final List<ArrangementSectionRule> sections = getSections();
for (ArrangementSectionRule section : sections) {
final List<StdArrangementMatchRule> extendedRules = new ArrayList<>();
for (StdArrangementMatchRule rule : section.getMatchRules()) {
appendExpandedRules(rule, extendedRules, tokenIdToDefinition);
}
myExtendedSectionRules.add(ArrangementSectionRule.create(section.getStartComment(), section.getEndComment(), extendedRules));
}
}
}
return myExtendedSectionRules;
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class ArrangementSettingsSerializationTest method rule.
private static StdArrangementMatchRule rule(boolean byName, @NotNull ArrangementSettingsToken... tokens) {
final List<ArrangementAtomMatchCondition> conditions = new ArrayList<>();
for (ArrangementSettingsToken token : tokens) {
conditions.add(new ArrangementAtomMatchCondition(token));
}
final StdArrangementEntryMatcher matcher = new StdArrangementEntryMatcher(new ArrangementCompositeMatchCondition(conditions));
return byName ? new StdArrangementMatchRule(matcher, BY_NAME) : new StdArrangementMatchRule(matcher);
}
Aggregations