use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class ArrangementMatchingRuleEditor method apply.
private void apply() {
final Pair<ArrangementMatchCondition, ArrangementSettingsToken> pair = buildCondition();
final Object modelValue;
if (pair == null) {
modelValue = new EmptyArrangementRuleComponent(myControl.getRowHeight(myRow));
} else {
modelValue = new StdArrangementMatchRule(new StdArrangementEntryMatcher(pair.first), pair.second);
}
myControl.getModel().set(myRow, modelValue);
myControl.repaintRows(myRow, myRow, true);
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class ArrangementSectionRuleManager method createDefaultSectionRule.
@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));
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class ArrangementSectionRulesControl method getSections.
public List<ArrangementSectionRule> getSections() {
if (getModel().getSize() <= 0) {
return Collections.emptyList();
}
final List<ArrangementSectionRule> result = ContainerUtil.newArrayList();
final List<StdArrangementMatchRule> buffer = ContainerUtil.newArrayList();
String currentSectionStart = null;
for (int i = 0; i < getModel().getSize(); i++) {
final Object element = getModel().getElementAt(i);
if (element instanceof StdArrangementMatchRule) {
final ArrangementSectionRuleData sectionRule = mySectionRuleManager == null ? null : mySectionRuleManager.getSectionRuleData((StdArrangementMatchRule) element);
if (sectionRule != null) {
if (sectionRule.isSectionStart()) {
appendBufferedSectionRules(result, buffer, currentSectionStart);
currentSectionStart = sectionRule.getText();
} else {
result.add(ArrangementSectionRule.create(StringUtil.notNullize(currentSectionStart), sectionRule.getText(), buffer));
buffer.clear();
currentSectionStart = null;
}
} else {
if (currentSectionStart == null) {
result.add(ArrangementSectionRule.create((StdArrangementMatchRule) element));
} else {
buffer.add((StdArrangementMatchRule) element);
}
}
}
}
appendBufferedSectionRules(result, buffer, currentSectionStart);
return result;
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project intellij-community by JetBrains.
the class ArrangementRuleAliasControl method setRuleSequences.
public void setRuleSequences(Collection<StdArrangementMatchRule> sequences) {
myComponents.clear();
getModel().clear();
if (sequences == null) {
return;
}
for (StdArrangementMatchRule rule : sequences) {
getModel().add(rule);
}
}
use of com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule in project android by JetBrains.
the class AndroidXmlPredefinedCodeStyle method apply.
@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;
}
Aggregations