下面列出了怎么用com.intellij.psi.codeStyle.arrangement.ArrangementEntry的API类实例代码及写法,或者点击链接到github查看源代码。
@SuppressWarnings("unchecked")
public ArrangementEntryWrapper(@Nonnull E entry) {
myEntry = entry;
myStartOffset = entry.getStartOffset();
myEndOffset = entry.getEndOffset();
ArrangementEntryWrapper<E> previous = null;
for (ArrangementEntry child : entry.getChildren()) {
ArrangementEntryWrapper<E> childWrapper = new ArrangementEntryWrapper<E>((E)child);
childWrapper.setParent(this);
if (previous != null) {
previous.setNext(childWrapper);
childWrapper.setPrevious(previous);
}
previous = childWrapper;
myChildren.add(childWrapper);
}
}
@Override
public int getBlankLines(@NotNull CodeStyleSettings settings,
@Nullable ArrangementEntry entry,
@Nullable ArrangementEntry entry2,
@NotNull ArrangementEntry entry3) {
return 0;
}
@Override
public boolean isMatched(@Nonnull 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;
}
@javax.annotation.Nullable
@Override
protected String getTextToMatch(@Nonnull ArrangementEntry entry) {
if (entry instanceof NamespaceAwareArrangementEntry) {
return ((NamespaceAwareArrangementEntry)entry).getNamespace();
}
else {
return null;
}
}
@Nullable
@Override
protected String getTextToMatch(@Nonnull ArrangementEntry entry) {
if (entry instanceof NameAwareArrangementEntry) {
return ((NameAwareArrangementEntry)entry).getName();
}
else {
return null;
}
}
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
for (ArrangementEntryMatcher matcher : myMatchers) {
if (!matcher.isMatched(entry)) {
return false;
}
}
return true;
}
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
if (myCompiledPattern == null) {
return false;
}
String text = getTextToMatch(entry);
return text != null && myCompiledPattern.matcher(text).matches();
}
@Override
public boolean isMatched(@Nonnull 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;
}
Entry(@Nullable ArrangementEntry parent, String name, TextRange range, boolean canBeMatched) {
super(parent, range.getStartOffset(), range.getEndOffset(), canBeMatched);
this.name = name;
}
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
return myDelegate.isMatched(entry);
}
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
return false;
}
@Nullable
protected abstract String getTextToMatch(@Nonnull ArrangementEntry entry);
/**
* Allows to check if given entry is matched by the current rule.
* <p/>
* Example: entry like 'public final field' should be matched by a 'final fields' rule but not matched by a 'private fields' rule.
*
* @param entry entry to check
* @return <code>true</code> if given entry is matched by the current rule; <code>false</code> otherwise
*/
boolean isMatched(@Nonnull ArrangementEntry entry);