use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class ArrangementSectionRule method createSectionRule.
@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));
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class ByModifierArrangementEntryMatcher method isMatched.
@Override
public boolean isMatched(@NotNull ArrangementEntry entry) {
if (entry instanceof ModifierAwareArrangementEntry) {
final Set<ArrangementSettingsToken> modifiers = ((ModifierAwareArrangementEntry) entry).getModifiers();
for (ArrangementAtomMatchCondition condition : myModifiers) {
final Object value = condition.getValue();
boolean isInverted = value instanceof Boolean && !((Boolean) value);
if (isInverted == modifiers.contains(condition.getType())) {
return false;
}
}
return true;
}
return false;
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class ByTypeArrangementEntryMatcher method isMatched.
@Override
public boolean isMatched(@NotNull ArrangementEntry entry) {
if (entry instanceof TypeAwareArrangementEntry) {
final Set<ArrangementSettingsToken> types = ((TypeAwareArrangementEntry) entry).getTypes();
for (ArrangementAtomMatchCondition condition : myTypes) {
final Object value = condition.getValue();
boolean isInverted = value instanceof Boolean && !((Boolean) value);
if (isInverted == types.contains(condition.getType())) {
return false;
}
}
return true;
}
return false;
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition in project intellij-community by JetBrains.
the class DefaultArrangementEntryMatcherSerializer method deserializeAtomCondition.
@Nullable
private ArrangementMatchCondition deserializeAtomCondition(@NotNull Element matcherElement) {
String id = matcherElement.getName();
ArrangementSettingsToken token = StdArrangementTokens.byId(id);
boolean processInnerText = true;
if (token != null && (StdArrangementTokens.General.TYPE.equals(token) || StdArrangementTokens.General.MODIFIER.equals(token))) {
// Backward compatibility with old arrangement settings format.
id = matcherElement.getText();
if (StringUtil.isEmpty(id)) {
LOG.warn("Can't deserialize match condition at legacy format");
return null;
}
token = StdArrangementTokens.byId(id);
processInnerText = false;
}
if (token == null) {
token = myMixin.deserializeToken(id);
}
if (token == null) {
LOG.warn(String.format("Can't deserialize match condition with id '%s'", id));
return null;
}
Object value = token;
String text = matcherElement.getText();
if (text != null && processInnerText) {
text = StringUtil.unescapeStringCharacters(matcherElement.getText());
if (!StringUtil.isEmpty(text)) {
final Boolean booleanValue = parseBooleanValue(text);
if (booleanValue != null) {
value = booleanValue;
} else {
value = text;
}
}
}
return new ArrangementAtomMatchCondition(token, value);
}
use of com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition 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