com.intellij.psi.codeStyle.arrangement.ArrangementEntry Java Examples

The following examples show how to use com.intellij.psi.codeStyle.arrangement.ArrangementEntry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArrangementEntryWrapper.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example #2
Source File: HaxeRearrangerModel.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public int getBlankLines(@NotNull CodeStyleSettings settings,
                         @Nullable ArrangementEntry entry,
                         @Nullable ArrangementEntry entry2,
                         @NotNull ArrangementEntry entry3) {
  return 0;
}
 
Example #3
Source File: ByModifierArrangementEntryMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #4
Source File: ByNamespaceArrangementEntryMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
protected String getTextToMatch(@Nonnull ArrangementEntry entry) {
  if (entry instanceof NamespaceAwareArrangementEntry) {
    return ((NamespaceAwareArrangementEntry)entry).getNamespace();
  }
  else {
    return null;
  }
}
 
Example #5
Source File: ByNameArrangementEntryMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected String getTextToMatch(@Nonnull ArrangementEntry entry) {
  if (entry instanceof NameAwareArrangementEntry) {
    return  ((NameAwareArrangementEntry)entry).getName();
  }
  else {
    return null;
  }
}
 
Example #6
Source File: CompositeArrangementEntryMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
  for (ArrangementEntryMatcher matcher : myMatchers) {
    if (!matcher.isMatched(entry)) {
      return false;
    }
  }
  return true;
}
 
Example #7
Source File: AbstractRegexpArrangementMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
  if (myCompiledPattern == null) {
    return false;
  }
  String text = getTextToMatch(entry);
  return text != null && myCompiledPattern.matcher(text).matches();
}
 
Example #8
Source File: ByTypeArrangementEntryMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #9
Source File: ProjectViewRearranger.java    From intellij with Apache License 2.0 4 votes vote down vote up
Entry(@Nullable ArrangementEntry parent, String name, TextRange range, boolean canBeMatched) {
  super(parent, range.getStartOffset(), range.getEndOffset(), canBeMatched);
  this.name = name;
}
 
Example #10
Source File: StdArrangementEntryMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
  return myDelegate.isMatched(entry);
}
 
Example #11
Source File: ArrangementEntryMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isMatched(@Nonnull ArrangementEntry entry) {
  return false;
}
 
Example #12
Source File: AbstractRegexpArrangementMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected abstract String getTextToMatch(@Nonnull ArrangementEntry entry);
 
Example #13
Source File: ArrangementEntryMatcher.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * 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);