Java 类com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher 实例源码

项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
@Test
public void testDefaultGroupingFilter() {
  final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME);
  final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);

  final StdArrangementSettings settings = new StdArrangementSettings();
  settings.addGrouping(groupingRule);
  settings.addRule(rule);
  final StdArrangementSettings defaultSettings = new StdArrangementSettings();
  defaultSettings.addGrouping(groupingRule);

  final Element holder = doSerializationTest(settings, defaultSettings);
  assertTrue(holder.getChildren().size() == 1);
  assertNull(holder.getChild("groups"));
  assertNotNull(holder.getChild("rules"));
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
@Test
public void testDefaultRulesFilter() {
  final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME);
  final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);

  final StdArrangementSettings settings = new StdArrangementSettings();
  settings.addGrouping(groupingRule);
  settings.addRule(rule);
  final StdArrangementSettings defaultSettings = new StdArrangementSettings();
  defaultSettings.addRule(rule);

  final Element holder = doSerializationTest(settings, defaultSettings);
  assertTrue(holder.getChildren().size() == 1);
  assertNotNull(holder.getChild("groups"));
  assertNull(holder.getChild("rules"));
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
@Test
public void testEmptyRules() throws Exception {
  final StdArrangementSettings settings = new StdArrangementSettings();
  settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));

  final StdArrangementSettings defaultSettings = new StdArrangementSettings();
  final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);
  defaultSettings.addRule(rule);

  final Element holder = doSerializationTest(settings, defaultSettings);
  assertTrue(holder.getChildren().size() == 2);
  final Element rules = holder.getChild("rules");
  assertNotNull(rules);
  assertTrue(rules.getChildren().isEmpty());
}
项目:intellij-ce-playground    文件:StdArrangementExtendableSettings.java   
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)));
  }
}
项目:consulo    文件:StdArrangementExtendableSettings.java   
public void appendExpandedRules(@Nonnull final StdArrangementMatchRule rule,
                                @Nonnull final List<StdArrangementMatchRule> rules,
                                @Nonnull 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)));
  }
}
项目:consulo-java    文件:JavaRearranger.java   
private static void and(@NotNull List<StdArrangementMatchRule> matchRules, @NotNull ArrangementSettingsToken... conditions)
{
    if(conditions.length == 1)
    {
        matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(conditions[0],
                conditions[0]))));
        return;
    }

    ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition();
    for(ArrangementSettingsToken condition : conditions)
    {
        composite.addOperand(new ArrangementAtomMatchCondition(condition, condition));
    }
    matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(composite)));
}
项目:intellij-ce-playground    文件:JavaRearranger.java   
private static void and(@NotNull List<StdArrangementMatchRule> matchRules, @NotNull ArrangementSettingsToken... conditions) {
  if (conditions.length == 1) {
    matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(
      conditions[0]
    ))));
    return;
  }

  ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition();
  for (ArrangementSettingsToken condition : conditions) {
    composite.addOperand(new ArrangementAtomMatchCondition(condition));
  }
  matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(composite)));
}
项目:intellij-ce-playground    文件:AbstractRearrangerTest.java   
@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));
  }
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
private static StdArrangementMatchRule rule(boolean byName, @NotNull ArrangementSettingsToken... tokens) {
  final List<ArrangementAtomMatchCondition> conditions = new ArrayList<ArrangementAtomMatchCondition>();
  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);
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
@Test
public void all() {
  final StdArrangementSettings settings = new StdArrangementSettings();
  settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
  final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
  doSerializationTest(settings, new StdArrangementSettings());
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
@Test
public void testDefaultFilter() {
  final StdArrangementSettings settings = new StdArrangementSettings();
  settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
  final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));

  final Element holder = doSerializationTest(settings, settings);
  assertTrue(holder.getChildren().isEmpty());
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
@Test
public void testEmptyGroupings() throws Exception {
  final StdArrangementSettings settings = new StdArrangementSettings();
  final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));

  final StdArrangementSettings defaultSettings = new StdArrangementSettings();
  defaultSettings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));

  final Element holder = doSerializationTest(settings, defaultSettings);
  assertTrue(holder.getChildren().size() == 2);
  final Element groups = holder.getChild("groups");
  assertNotNull(groups);
  assertTrue(groups.getChildren().isEmpty());
}
项目:intellij-ce-playground    文件:ArrangementSectionRuleManager.java   
@NotNull
public StdArrangementMatchRule createDefaultSectionRule() {
  final ArrangementAtomMatchCondition type = new ArrangementAtomMatchCondition(START_SECTION);
  final ArrangementAtomMatchCondition text = new ArrangementAtomMatchCondition(TEXT, createDefaultSectionText());
  final ArrangementMatchCondition condition = ArrangementUtil.combine(type, text);
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition));
}
项目:intellij-ce-playground    文件:XmlRearranger.java   
@NotNull
public static StdArrangementMatchRule attrArrangementRule(@NotNull String nameFilter,
                                                          @NotNull String namespaceFilter,
                                                          @NotNull ArrangementSettingsToken orderType) {
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine(
    new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter),
    new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter)
  )), orderType);
}
项目:tools-idea    文件:JavaRearranger.java   
private static void and(@NotNull List<StdArrangementMatchRule> matchRules, @NotNull ArrangementSettingsToken... conditions) {
  if (conditions.length == 1) {
    matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(
      conditions[0], conditions[0]
    ))));
    return;
  }

  ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition();
  for (ArrangementSettingsToken condition : conditions) {
    composite.addOperand(new ArrangementAtomMatchCondition(condition, condition));
  }
  matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(composite)));
}
项目:tools-idea    文件:ArrangementSettingsSerializationTest.java   
@Test
public void all() {
  StdArrangementSettings settings = new StdRulePriorityAwareSettings();
  settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
  ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));

  Element holder = new Element("holder");
  ArrangementSettingsSerializer instance = DefaultArrangementSettingsSerializer.INSTANCE;
  instance.serialize(settings, holder);
  ArrangementSettings restored = instance.deserialize(holder);
  assertEquals(settings, restored);
}
项目:tools-idea    文件:XmlRearranger.java   
@NotNull
public static StdArrangementMatchRule attrArrangementRule(@NotNull String nameFilter,
                                                          @NotNull String namespaceFilter,
                                                          @NotNull ArrangementSettingsToken orderType) {
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine(
    new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter),
    new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter)
  )), orderType);
}
项目:consulo    文件:ArrangementSettingsSerializationTest.java   
@Test
public void all() {
  StdArrangementSettings settings = new StdArrangementSettings();
  settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
  ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
  settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));

  Element holder = new Element("holder");
  ArrangementSettingsSerializer instance = new DefaultArrangementSettingsSerializer(settings);
  instance.serialize(settings, holder);
  ArrangementSettings restored = instance.deserialize(holder);
  assertEquals(settings, restored);
}
项目:consulo    文件:ArrangementSectionRuleManager.java   
@Nonnull
public StdArrangementMatchRule createDefaultSectionRule() {
  final ArrangementAtomMatchCondition type = new ArrangementAtomMatchCondition(START_SECTION);
  final ArrangementAtomMatchCondition text = new ArrangementAtomMatchCondition(TEXT, createDefaultSectionText());
  final ArrangementMatchCondition condition = ArrangementUtil.combine(type, text);
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition));
}
项目:consulo-xml    文件:XmlRearranger.java   
@NotNull
public static StdArrangementMatchRule attrArrangementRule(
        @NotNull String nameFilter, @NotNull String namespaceFilter, @NotNull ArrangementSettingsToken orderType)
{
    return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine(new ArrangementAtomMatchCondition
            (StdArrangementTokens.Regexp.NAME, nameFilter), new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE,
            namespaceFilter))), orderType);
}
项目:intellij-ce-playground    文件:AbstractRearrangerTest.java   
@NotNull
protected static StdArrangementMatchRule rule(@NotNull ArrangementSettingsToken token) {
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(atom(token)));
}
项目:intellij-ce-playground    文件:AbstractRearrangerTest.java   
@NotNull
protected static StdArrangementMatchRule rule(@NotNull ArrangementAtomMatchCondition... conditions) {
  ArrangementMatchCondition compositeCondition = ArrangementUtil.combine(conditions);
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(compositeCondition));
}