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

项目:intellij-ce-playground    文件:CommonCodeStyleSettings.java   
public void writeExternal(Element element) throws WriteExternalException {
  CommonCodeStyleSettings defaultSettings = getDefaultSettings();
  Set<String> supportedFields = getSupportedFields();
  if (supportedFields != null) {
    supportedFields.add("PARENT_SETTINGS_INSTALLED");
    supportedFields.add("FORCE_REARRANGE_MODE");
  }
  DefaultJDOMExternalizer.writeExternal(this, element, new SupportedFieldsDiffFilter(this, supportedFields, defaultSettings));
  if (myIndentOptions != null) {
    IndentOptions defaultIndentOptions = defaultSettings != null ? defaultSettings.getIndentOptions() : null;
    Element indentOptionsElement = new Element(INDENT_OPTIONS_TAG);
    myIndentOptions.serialize(indentOptionsElement, defaultIndentOptions);
    if (!indentOptionsElement.getChildren().isEmpty()) {
      element.addContent(indentOptionsElement);
    }
  }

  if (myArrangementSettings != null) {
    Element container = new Element(ARRANGEMENT_ELEMENT_NAME);
    ArrangementUtil.writeExternal(container, myArrangementSettings, myLanguage);
    if (!container.getChildren().isEmpty()) {
      element.addContent(container);
    }
  }
}
项目:intellij-ce-playground    文件:StdArrangementMatchRule.java   
@Override
public int compareTo(@NotNull StdArrangementMatchRule o) {
  final Map<ArrangementSettingsToken, Object> tokenValues = ArrangementUtil.extractTokens(getMatcher().getCondition());
  final Map<ArrangementSettingsToken, Object> tokenValues1 = ArrangementUtil.extractTokens(o.getMatcher().getCondition());
  final Set<ArrangementSettingsToken> tokens = tokenValues.keySet();
  final Set<ArrangementSettingsToken> tokens1 = tokenValues1.keySet();
  if (tokens1.containsAll(tokens)) {
    return tokens.containsAll(tokens1) ? 0 : 1;
  }
  else {
    if (tokens.containsAll(tokens1)) {
      return -1;
    }

    final String entryType = getEntryType(tokenValues);
    final String entryType1 = getEntryType(tokenValues1);
    final int compare = StringUtil.compare(entryType1, entryType, false);
    if (compare != 0 || tokens.size() == tokens1.size()) {
      return compare;
    }
    return tokens.size() < tokens1.size() ? 1 : -1;
  }
}
项目:intellij-ce-playground    文件:ArrangementMatchingRuleEditor.java   
@Nullable
private Pair<ArrangementMatchCondition, ArrangementSettingsToken> buildCondition() {
  List<ArrangementMatchCondition> conditions = ContainerUtilRt.newArrayList();
  ArrangementSettingsToken orderType = null;
  for (ArrangementUiComponent component : myComponents.values()) {
    if (!component.isEnabled() || !component.isSelected()) {
      continue;
    }
    ArrangementSettingsToken token = component.getToken();
    if (token != null && StdArrangementTokenType.ORDER.is(token)) {
      orderType = token;
    }
    else {
      conditions.add(component.getMatchCondition());
    }
  }
  if (!conditions.isEmpty()) {
    if (orderType == null) {
      orderType = StdArrangementTokens.Order.KEEP;
    }
    return Pair.create(ArrangementUtil.combine(conditions.toArray(new ArrangementMatchCondition[conditions.size()])), orderType);
  }
  else {
    return null;
  }
}
项目:tools-idea    文件:CommonCodeStyleSettings.java   
public void writeExternal(Element element) throws WriteExternalException {
  CommonCodeStyleSettings defaultSettings = getDefaultSettings();
  Set<String> supportedFields = getSupportedFields();
  if (supportedFields != null) {
    supportedFields.add("PARENT_SETTINGS_INSTALLED");
  }
  DefaultJDOMExternalizer.writeExternal(this, element, new SupportedFieldsDiffFilter(this, supportedFields, defaultSettings));
  if (myIndentOptions != null) {
    IndentOptions defaultIndentOptions = defaultSettings != null ? defaultSettings.getIndentOptions() : null;
    Element indentOptionsElement = new Element(INDENT_OPTIONS_TAG);
    myIndentOptions.serialize(indentOptionsElement, defaultIndentOptions);
    if (!indentOptionsElement.getChildren().isEmpty()) {
      element.addContent(indentOptionsElement);
    }
  }

  if (myArrangementSettings != null) {
    Element container = new Element(ARRANGEMENT_ELEMENT_NAME);
    ArrangementUtil.writeExternal(container, myArrangementSettings, myLanguage);
    if (!container.getChildren().isEmpty()) {
      element.addContent(container);
    }
  }
}
项目:tools-idea    文件:ArrangementMatchingRuleEditor.java   
@Nullable
private Pair<ArrangementMatchCondition, ArrangementSettingsToken> buildCondition() {
  List<ArrangementMatchCondition> conditions = ContainerUtilRt.newArrayList();
  ArrangementSettingsToken orderType = null;
  for (ArrangementUiComponent component : myComponents.values()) {
    if (!component.isEnabled() || !component.isSelected()) {
      continue;
    }
    ArrangementSettingsToken token = component.getToken();
    if (token != null && StdArrangementTokens.Order.is(token)) {
      orderType = token;
    }
    else {
      conditions.add(component.getMatchCondition());
    }
  }
  if (orderType != null && !conditions.isEmpty()) {
    return Pair.create(ArrangementUtil.combine(conditions.toArray(new ArrangementMatchCondition[conditions.size()])), orderType);
  }
  else {
    return null;
  }
}
项目:consulo    文件:CommonCodeStyleSettings.java   
public void writeExternal(Element element) throws WriteExternalException {
  CommonCodeStyleSettings defaultSettings = getDefaultSettings();
  Set<String> supportedFields = getSupportedFields();
  if (supportedFields != null) {
    supportedFields.add("PARENT_SETTINGS_INSTALLED");
    supportedFields.add("FORCE_REARRANGE_MODE");
  }
  DefaultJDOMExternalizer.writeExternal(this, element, new SupportedFieldsDiffFilter(this, supportedFields, defaultSettings));
  if (myIndentOptions != null) {
    IndentOptions defaultIndentOptions = defaultSettings != null ? defaultSettings.getIndentOptions() : null;
    Element indentOptionsElement = new Element(INDENT_OPTIONS_TAG);
    myIndentOptions.serialize(indentOptionsElement, defaultIndentOptions);
    if (!indentOptionsElement.getChildren().isEmpty()) {
      element.addContent(indentOptionsElement);
    }
  }

  if (myArrangementSettings != null) {
    Element container = new Element(ARRANGEMENT_ELEMENT_NAME);
    ArrangementUtil.writeExternal(container, myArrangementSettings, myLanguage);
    if (!container.getChildren().isEmpty()) {
      element.addContent(container);
    }
  }
}
项目:consulo    文件:StdArrangementMatchRule.java   
@Override
public int compareTo(@Nonnull StdArrangementMatchRule o) {
  final Set<ArrangementSettingsToken> tokens = ArrangementUtil.extractTokens(getMatcher().getCondition()).keySet();
  final Set<ArrangementSettingsToken> tokens1 = ArrangementUtil.extractTokens(o.getMatcher().getCondition()).keySet();
  if (tokens1.containsAll(tokens)) {
    return tokens.containsAll(tokens1) ? 0 : 1;
  }
  else {
    if (tokens.containsAll(tokens1)) {
      return -1;
    }

    final String entryType = getEntryType(tokens);
    final String entryType1 = getEntryType(tokens1);
    final int compare = StringUtil.compare(entryType, entryType1, false);
    if (compare != 0 || tokens.size() == tokens1.size()) {
      return compare;
    }
    return tokens.size() < tokens1.size() ? 1 : -1;
  }
}
项目:consulo    文件:ArrangementMatchingRuleEditor.java   
@Nullable
private Pair<ArrangementMatchCondition, ArrangementSettingsToken> buildCondition() {
  List<ArrangementMatchCondition> conditions = ContainerUtilRt.newArrayList();
  ArrangementSettingsToken orderType = null;
  for (ArrangementUiComponent component : myComponents.values()) {
    if (!component.isEnabled() || !component.isSelected()) {
      continue;
    }
    ArrangementSettingsToken token = component.getToken();
    if (token != null && StdArrangementTokenType.ORDER.is(token)) {
      orderType = token;
    }
    else {
      conditions.add(component.getMatchCondition());
    }
  }
  if (!conditions.isEmpty()) {
    if (orderType == null) {
      orderType = StdArrangementTokens.Order.KEEP;
    }
    return Pair.create(ArrangementUtil.combine(conditions.toArray(new ArrangementMatchCondition[conditions.size()])), orderType);
  }
  else {
    return null;
  }
}
项目:intellij-ce-playground    文件:CommonCodeStyleSettings.java   
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  if (myIndentOptions != null) {
    Element indentOptionsElement = element.getChild(INDENT_OPTIONS_TAG);
    if (indentOptionsElement != null) {
      myIndentOptions.deserialize(indentOptionsElement);
    }
  }
  Element arrangementRulesContainer = element.getChild(ARRANGEMENT_ELEMENT_NAME);
  if (arrangementRulesContainer != null) {
    myArrangementSettings = ArrangementUtil.readExternal(arrangementRulesContainer, myLanguage);
  }
}
项目:intellij-ce-playground    文件:ArrangementStandardSettingsManager.java   
@NotNull
public ArrangementEntryMatcher buildMatcher(@NotNull ArrangementMatchCondition condition) throws IllegalArgumentException {
  ArrangementEntryMatcher matcher = ArrangementUtil.buildMatcher(condition);
  if (matcher == null) {
    matcher = myDelegate.buildMatcher(condition);
  }
  return matcher;
}
项目: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));
}
项目:tools-idea    文件:CommonCodeStyleSettings.java   
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  if (myIndentOptions != null) {
    Element indentOptionsElement = element.getChild(INDENT_OPTIONS_TAG);
    if (indentOptionsElement != null) {
      myIndentOptions.deserialize(indentOptionsElement);
    }
  }
  Element arrangementRulesContainer = element.getChild(ARRANGEMENT_ELEMENT_NAME);
  if (arrangementRulesContainer != null) {
    myArrangementSettings = ArrangementUtil.readExternal(arrangementRulesContainer, myLanguage);
  }
}
项目:tools-idea    文件:ArrangementStandardSettingsManager.java   
@NotNull
public ArrangementEntryMatcher buildMatcher(@NotNull ArrangementMatchCondition condition) throws IllegalArgumentException {
  ArrangementEntryMatcher matcher = ArrangementUtil.buildMatcher(condition);
  if (matcher == null) {
    matcher = myDelegate.buildMatcher(condition);
  }
  return matcher;
}
项目:tools-idea    文件:StdArrangementMatchRule.java   
@Override
public int compareTo(@NotNull StdArrangementMatchRule o) {
  final Set<ArrangementSettingsToken> tokens = ArrangementUtil.extractTokens(getMatcher().getCondition()).keySet();
  final Set<ArrangementSettingsToken> tokens1 = ArrangementUtil.extractTokens(o.getMatcher().getCondition()).keySet();
  if (tokens1.containsAll(tokens)) {
    return tokens.containsAll(tokens1) ? 0 : 1;
  }
  else {
    return tokens.containsAll(tokens1) ? -1 : 0;
  }
}
项目: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    文件:CommonCodeStyleSettings.java   
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  if (myIndentOptions != null) {
    Element indentOptionsElement = element.getChild(INDENT_OPTIONS_TAG);
    if (indentOptionsElement != null) {
      myIndentOptions.deserialize(indentOptionsElement);
    }
  }
  Element arrangementRulesContainer = element.getChild(ARRANGEMENT_ELEMENT_NAME);
  if (arrangementRulesContainer != null) {
    myArrangementSettings = ArrangementUtil.readExternal(arrangementRulesContainer, myLanguage);
  }
}
项目:consulo    文件:ArrangementStandardSettingsManager.java   
@Nonnull
public ArrangementEntryMatcher buildMatcher(@Nonnull ArrangementMatchCondition condition) throws IllegalArgumentException {
  ArrangementEntryMatcher matcher = ArrangementUtil.buildMatcher(condition);
  if (matcher == null) {
    matcher = myDelegate.buildMatcher(condition);
  }
  return matcher;
}
项目:consulo    文件:ArrangementSectionRule.java   
@Nullable
private static StdArrangementMatchRule createSectionRule(@Nullable String comment, @Nonnull ArrangementSettingsToken token) {
  if (StringUtil.isEmpty(comment)) {
    return null;
  }
  final ArrangementAtomMatchCondition type = new ArrangementAtomMatchCondition(token);
  final ArrangementAtomMatchCondition text = new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.TEXT, comment);
  final ArrangementMatchCondition condition = ArrangementUtil.combine(type, text);
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition));
}
项目: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    文件:StdArrangementSettings.java   
@NotNull
@Override
public List<StdArrangementMatchRule> getRules() {
  return ArrangementUtil.collectMatchRules(mySectionRules);
}
项目:intellij-ce-playground    文件:ArrangementSectionRule.java   
@NotNull
private static StdArrangementMatchRule createSectionRule(@NotNull String comment, @NotNull ArrangementSettingsToken token) {
  final ArrangementAtomMatchCondition text = new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.TEXT, comment);
  final ArrangementMatchCondition condition = ArrangementUtil.combine(new ArrangementAtomMatchCondition(token), text);
  return new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition));
}
项目:consulo    文件:StdArrangementSettings.java   
@Nonnull
@Override
public List<StdArrangementMatchRule> getRules() {
  return ArrangementUtil.collectMatchRules(mySectionRules);
}