Java 类com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings 实例源码

项目: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    文件:ArrangementSettingsSerializationTest.java   
private static Element doSerializationTest(@NotNull StdArrangementSettings settings, @NotNull StdArrangementSettings defaultSettings) {
  Element holder = new Element("holder");
  ArrangementSettingsSerializer instance = new TestArrangementSettingsSerializer(defaultSettings);
  instance.serialize(settings, holder);
  ArrangementSettings restored = instance.deserialize(holder);
  assertEquals(settings, restored);
  return holder;
}
项目: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    文件:AndroidXmlPredefinedCodeStyle.java   
@Override
public void apply(CodeStyleSettings settings) {
  final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(XmlFileType.INSTANCE);
  indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.INDENT_SIZE;

  XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class);
  xmlSettings.XML_ALIGN_ATTRIBUTES = false;
  xmlSettings.XML_SPACE_INSIDE_EMPTY_TAG = true;
  xmlSettings.XML_KEEP_LINE_BREAKS = false;

  final AndroidXmlCodeStyleSettings androidSettings = AndroidXmlCodeStyleSettings.getInstance(settings);
  androidSettings.USE_CUSTOM_SETTINGS = true;

  androidSettings.LAYOUT_SETTINGS = new AndroidXmlCodeStyleSettings.LayoutSettings();
  androidSettings.MANIFEST_SETTINGS = new AndroidXmlCodeStyleSettings.ManifestSettings();
  androidSettings.VALUE_RESOURCE_FILE_SETTINGS = new AndroidXmlCodeStyleSettings.ValueResourceFileSettings();
  androidSettings.OTHER_SETTINGS = new AndroidXmlCodeStyleSettings.OtherSettings();

  // arrangement
  final List<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>();
  rules.add(attrArrangementRule("xmlns:android", "", KEEP));
  rules.add(attrArrangementRule("xmlns:.*", "", BY_NAME));
  rules.add(attrArrangementRule(".*:id", SdkConstants.NS_RESOURCES, KEEP));
  rules.add(attrArrangementRule(".*:name", SdkConstants.NS_RESOURCES, KEEP));
  rules.add(attrArrangementRule("name", "^$", KEEP));
  rules.add(attrArrangementRule("style", "^$", KEEP));
  rules.add(attrArrangementRule(".*", "^$", BY_NAME));
  rules.add(attrArrangementRule(".*:layout_width", SdkConstants.NS_RESOURCES, KEEP));
  rules.add(attrArrangementRule(".*:layout_height", SdkConstants.NS_RESOURCES, KEEP));
  rules.add(attrArrangementRule(".*:layout_.*", SdkConstants.NS_RESOURCES, BY_NAME));
  rules.add(attrArrangementRule(".*:width", SdkConstants.NS_RESOURCES, BY_NAME));
  rules.add(attrArrangementRule(".*:height", SdkConstants.NS_RESOURCES, BY_NAME));
  rules.add(attrArrangementRule(".*", SdkConstants.NS_RESOURCES, BY_NAME));
  rules.add(attrArrangementRule(".*", ".*", BY_NAME));
  // TODO: Should sort name:"color",namespace:"" to the end (primarily for color state lists)
  final CommonCodeStyleSettings xmlCommonSettings = settings.getCommonSettings(XMLLanguage.INSTANCE);
  xmlCommonSettings.setArrangementSettings(
    StdArrangementSettings.createByMatchRules(ContainerUtil.<ArrangementGroupingRule>emptyList(), rules));
  xmlCommonSettings.FORCE_REARRANGE_MODE = CommonCodeStyleSettings.REARRANGE_ALWAYS;
}
项目: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    文件:DefaultArrangementSettingsSerializer.java   
@Override
public void serialize(@NotNull ArrangementSettings s, @NotNull Element holder) {
  if (!(s instanceof StdArrangementSettings)) {
    return;
  }

  StdArrangementSettings settings = (StdArrangementSettings)s;

  List<ArrangementGroupingRule> groupings = settings.getGroupings();
  if (!groupings.isEmpty()) {
    Element groupingsElement = new Element(GROUPS_ELEMENT_NAME);
    holder.addContent(groupingsElement);
    for (ArrangementGroupingRule group : groupings) {
      Element groupElement = new Element(GROUP_ELEMENT_NAME);
      groupingsElement.addContent(groupElement);
      groupElement.addContent(new Element(TYPE_ELEMENT_NAME).setText(group.getGroupingType().getId()));
      groupElement.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(group.getOrderType().getId()));
    }
  }

  List<StdArrangementMatchRule> rules = settings.getRules();
  if (!rules.isEmpty()) {
    Element rulesElement = new Element(RULES_ELEMENT_NAME);
    holder.addContent(rulesElement);
    for (StdArrangementMatchRule rule : rules) {
      rulesElement.addContent(serialize(rule));
    }
  }
}
项目: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);
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
private static StdArrangementSettings settings(@NotNull List<ArrangementGroupingRule> groupings,
                                               @NotNull List<ArrangementSectionRule> sections) {
  return new StdArrangementSettings(groupings, sections);
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
private static StdArrangementSettings emptySettings() {
  return new StdArrangementSettings(ContainerUtil.<ArrangementGroupingRule>emptyList(), ContainerUtil.<ArrangementSectionRule>emptyList());
}
项目:intellij-ce-playground    文件:ArrangementSettingsSerializationTest.java   
public TestArrangementSettingsSerializer(@NotNull StdArrangementSettings defaultSettings) {
  super(defaultSettings);
}
项目:tools-idea    文件:ArrangementStandardSettingsManager.java   
/**
 * @see ArrangementStandardSettingsAware#getDefaultSettings()
 */
@Nullable
public StdArrangementSettings getDefaultSettings() {
  return myDefaultSettings;
}
项目:consulo-xml    文件:XmlRearranger.java   
@Nullable
@Override
public StdArrangementSettings getDefaultSettings()
{
    return DEFAULT_SETTINGS;
}
项目:consulo-java    文件:JavaRearranger.java   
@NotNull
@Override
public StdArrangementSettings getDefaultSettings()
{
    return DEFAULT_SETTINGS;
}