本文整理汇总了Java中com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule类的典型用法代码示例。如果您正苦于以下问题:Java ArrangementMatchRule类的具体用法?Java ArrangementMatchRule怎么用?Java ArrangementMatchRule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrangementMatchRule类属于com.intellij.psi.codeStyle.arrangement.match包,在下文中一共展示了ArrangementMatchRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arrangeByRule
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@Nullable
private static <E extends ArrangementEntry> Collection<E> arrangeByRule(@NotNull List<E> arranged,
@NotNull MultiMap<ArrangementMatchRule, E> elementsByRule,
@NotNull ArrangementMatchRule rule) {
if (elementsByRule.containsKey(rule)) {
final Collection<E> arrangedEntries = elementsByRule.remove(rule);
// Sort by name if necessary.
if (StdArrangementTokens.Order.BY_NAME.equals(rule.getOrderType())) {
sortByName((List<E>)arrangedEntries);
}
arranged.addAll(arrangedEntries);
return arrangedEntries;
}
return null;
}
示例2: arrangeByRule
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@Nullable
private static <E extends ArrangementEntry> Collection<E> arrangeByRule(@Nonnull List<E> arranged,
@Nonnull MultiMap<ArrangementMatchRule, E> elementsByRule,
@Nonnull ArrangementMatchRule rule) {
if (elementsByRule.containsKey(rule)) {
final Collection<E> arrangedEntries = elementsByRule.remove(rule);
// Sort by name if necessary.
if (StdArrangementTokens.Order.BY_NAME.equals(rule.getOrderType())) {
sortByName((List<E>)arrangedEntries);
}
arranged.addAll(arrangedEntries);
return arrangedEntries;
}
return null;
}
示例3: getRulesSortedByPriority
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@NotNull
@Override
public List<? extends ArrangementMatchRule> getRulesSortedByPriority() {
synchronized (myRulesByPriority) {
if (myRulesByPriority.isEmpty()) {
for (ArrangementSectionRule rule : mySectionRules) {
myRulesByPriority.addAll(rule.getMatchRules());
}
ContainerUtil.sort(myRulesByPriority);
}
}
return myRulesByPriority;
}
示例4: getRulesSortedByPriority
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@NotNull
@Override
public List<? extends ArrangementMatchRule> getRulesSortedByPriority() {
synchronized (myExtendedSectionRules) {
if (myRulesByPriority.isEmpty()) {
for (ArrangementSectionRule rule : getExtendedSectionRules()) {
myRulesByPriority.addAll(rule.getMatchRules());
}
ContainerUtil.sort(myRulesByPriority);
}
}
return myRulesByPriority;
}
示例5: Context
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
private Context(@NotNull Rearranger<E> rearranger,
@NotNull Collection<ArrangementEntryWrapper<E>> wrappers,
@NotNull Document document,
@NotNull List<ArrangementSectionRule> sectionRules,
@NotNull List<? extends ArrangementMatchRule> rulesByPriority,
@NotNull CodeStyleSettings settings, @NotNull Changer changer)
{
this.rearranger = rearranger;
this.wrappers = wrappers;
this.document = document;
this.sectionRules = sectionRules;
this.rulesByPriority = rulesByPriority;
this.settings = settings;
this.changer = changer;
}
示例6: from
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
public static <T extends ArrangementEntry> Context<T> from(@NotNull Rearranger<T> rearranger,
@NotNull Document document,
@NotNull PsiElement root,
@NotNull Collection<TextRange> ranges,
@NotNull ArrangementSettings arrangementSettings,
@NotNull CodeStyleSettings codeStyleSettings)
{
Collection<T> entries = rearranger.parse(root, document, ranges, arrangementSettings);
Collection<ArrangementEntryWrapper<T>> wrappers = new ArrayList<ArrangementEntryWrapper<T>>();
ArrangementEntryWrapper<T> previous = null;
for (T entry : entries) {
ArrangementEntryWrapper<T> wrapper = new ArrangementEntryWrapper<T>(entry);
if (previous != null) {
previous.setNext(wrapper);
wrapper.setPrevious(previous);
}
wrappers.add(wrapper);
previous = wrapper;
}
Changer changer;
if (document instanceof DocumentEx) {
changer = new RangeMarkerAwareChanger<T>((DocumentEx)document);
}
else {
changer = new DefaultChanger();
}
final List<? extends ArrangementMatchRule> rulesByPriority = arrangementSettings.getRulesSortedByPriority();
final List<ArrangementSectionRule> sectionRules = ArrangementUtil.getExtendedSectionRules(arrangementSettings);
return new Context<T>(rearranger, wrappers, document, sectionRules, rulesByPriority, codeStyleSettings, changer);
}
示例7: getRulesSortedByPriority
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@NotNull
@Override
public List<? extends ArrangementMatchRule> getRulesSortedByPriority() {
if (myRulesByPriority.isEmpty()) {
myRulesByPriority.addAll(myRules);
ContainerUtil.sort(myRulesByPriority);
}
return myRulesByPriority;
}
示例8: serialize
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@Nullable
public Element serialize(@NotNull ArrangementMatchRule rule) {
Element matcherElement = myMatcherSerializer.serialize(rule.getMatcher());
if (matcherElement == null) {
return null;
}
Element result = new Element(RULE_ELEMENT_NAME);
result.addContent(new Element(MATCHER_ELEMENT_NAME).addContent(matcherElement));
if (rule.getOrderType() != ArrangementMatchRule.DEFAULT_ORDER_TYPE) {
result.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(rule.getOrderType().getId()));
}
return result;
}
示例9: Context
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
private Context(@NotNull Rearranger<E> rearranger,
@NotNull Collection<ArrangementEntryWrapper<E>> wrappers,
@NotNull Document document,
@NotNull List<? extends ArrangementMatchRule> rules,
@NotNull List<? extends ArrangementMatchRule> rulesByPriority,
@NotNull CodeStyleSettings settings, @NotNull Changer changer)
{
this.rearranger = rearranger;
this.wrappers = wrappers;
this.document = document;
this.rules = rules;
this.rulesByPriority = rulesByPriority;
this.settings = settings;
this.changer = changer;
}
示例10: from
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
public static <T extends ArrangementEntry> Context<T> from(@NotNull Rearranger<T> rearranger,
@NotNull Document document,
@NotNull PsiElement root,
@NotNull Collection<TextRange> ranges,
@NotNull ArrangementSettings arrangementSettings,
@NotNull CodeStyleSettings codeStyleSettings)
{
Collection<T> entries = rearranger.parse(root, document, ranges, arrangementSettings);
Collection<ArrangementEntryWrapper<T>> wrappers = new ArrayList<ArrangementEntryWrapper<T>>();
ArrangementEntryWrapper<T> previous = null;
for (T entry : entries) {
ArrangementEntryWrapper<T> wrapper = new ArrangementEntryWrapper<T>(entry);
if (previous != null) {
previous.setNext(wrapper);
wrapper.setPrevious(previous);
}
wrappers.add(wrapper);
previous = wrapper;
}
Changer changer;
if (document instanceof DocumentEx) {
changer = new RangeMarkerAwareChanger<T>((DocumentEx)document);
}
else {
changer = new DefaultChanger();
}
final List<? extends ArrangementMatchRule> rulesByPriority = ArrangementUtil.getRulesSortedByPriority(arrangementSettings);
return new Context<T>(rearranger, wrappers, document, arrangementSettings.getRules(), rulesByPriority, codeStyleSettings, changer);
}
示例11: getRulesSortedByPriority
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@Nonnull
@Override
public List<? extends ArrangementMatchRule> getRulesSortedByPriority() {
synchronized (myRulesByPriority) {
if (myRulesByPriority.isEmpty()) {
for (ArrangementSectionRule rule : mySectionRules) {
myRulesByPriority.addAll(rule.getMatchRules());
}
ContainerUtil.sort(myRulesByPriority);
}
}
return myRulesByPriority;
}
示例12: getRulesSortedByPriority
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
@Nonnull
@Override
public List<? extends ArrangementMatchRule> getRulesSortedByPriority() {
synchronized (myExtendedSectionRules) {
if (myRulesByPriority.isEmpty()) {
for (ArrangementSectionRule rule : getExtendedSectionRules()) {
myRulesByPriority.addAll(rule.getMatchRules());
}
ContainerUtil.sort(myRulesByPriority);
}
}
return myRulesByPriority;
}
示例13: Context
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
private Context(@Nonnull Rearranger<E> rearranger,
@Nonnull Collection<ArrangementEntryWrapper<E>> wrappers,
@Nonnull Document document,
@Nonnull List<ArrangementSectionRule> sectionRules,
@Nonnull List<? extends ArrangementMatchRule> rulesByPriority,
@Nonnull CodeStyleSettings settings, @Nonnull Changer changer)
{
this.rearranger = rearranger;
this.wrappers = wrappers;
this.document = document;
this.sectionRules = sectionRules;
this.rulesByPriority = rulesByPriority;
this.settings = settings;
this.changer = changer;
}
示例14: from
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
public static <T extends ArrangementEntry> Context<T> from(@Nonnull Rearranger<T> rearranger,
@Nonnull Document document,
@Nonnull PsiElement root,
@Nonnull Collection<TextRange> ranges,
@Nonnull ArrangementSettings arrangementSettings,
@Nonnull CodeStyleSettings codeStyleSettings)
{
Collection<T> entries = rearranger.parse(root, document, ranges, arrangementSettings);
Collection<ArrangementEntryWrapper<T>> wrappers = new ArrayList<ArrangementEntryWrapper<T>>();
ArrangementEntryWrapper<T> previous = null;
for (T entry : entries) {
ArrangementEntryWrapper<T> wrapper = new ArrangementEntryWrapper<T>(entry);
if (previous != null) {
previous.setNext(wrapper);
wrapper.setPrevious(previous);
}
wrappers.add(wrapper);
previous = wrapper;
}
Changer changer;
if (document instanceof DocumentEx) {
changer = new RangeMarkerAwareChanger<T>((DocumentEx)document);
}
else {
changer = new DefaultChanger();
}
final List<? extends ArrangementMatchRule> rulesByPriority = arrangementSettings.getRulesSortedByPriority();
final List<ArrangementSectionRule> sectionRules = ArrangementUtil.getExtendedSectionRules(arrangementSettings);
return new Context<T>(rearranger, wrappers, document, sectionRules, rulesByPriority, codeStyleSettings, changer);
}
示例15: getAnchor
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule; //导入依赖的package包/类
/**
* Tries to find an element at the given context which should be the previous sibling for the given 'member'element according to the
* {@link CommonCodeStyleSettings#getArrangementSettings() user-defined arrangement rules}.
* <p/>
* E.g. the IDE might generate given 'member' element and wants to know element after which it should be inserted
*
* @param member target member which anchor should be calculated
* @param settings code style settings to use
* @param context given member's context
* @return given member's anchor if the one can be computed;
* given 'context' element if given member should be the first child
* <code>null</code> otherwise
*/
@SuppressWarnings("MethodMayBeStatic")
@Nullable
public PsiElement getAnchor(@NotNull PsiElement member, @NotNull CommonCodeStyleSettings settings, @NotNull PsiElement context) {
Language language = context.getLanguage();
Rearranger<?> rearranger = Rearranger.EXTENSION.forLanguage(language);
if (rearranger == null) {
return null;
}
ArrangementSettings arrangementSettings = settings.getArrangementSettings();
if (arrangementSettings == null && rearranger instanceof ArrangementStandardSettingsAware) {
arrangementSettings = ((ArrangementStandardSettingsAware)rearranger).getDefaultSettings();
}
if (arrangementSettings == null) {
return null;
}
Pair<? extends ArrangementEntry,? extends List<? extends ArrangementEntry>> pair =
rearranger.parseWithNew(context, null, Collections.singleton(context.getTextRange()), member, arrangementSettings);
if (pair == null || pair.second.isEmpty()) {
return null;
}
ArrangementEntry memberEntry = pair.first;
List<? extends ArrangementEntry> entries = pair.second;
ArrangementEntry parentEntry = entries.get(0);
List<? extends ArrangementEntry> nonArranged = parentEntry.getChildren();
List<ArrangementEntry> entriesWithNew = new ArrayList<ArrangementEntry>(nonArranged);
entriesWithNew.add(memberEntry);
//TODO: check insert new element
final List<? extends ArrangementMatchRule> rulesByPriority = arrangementSettings.getRulesSortedByPriority();
final List<ArrangementSectionRule> extendedSectionRules = ArrangementUtil.getExtendedSectionRules(arrangementSettings);
List<ArrangementEntry> arranged = ArrangementEngine.arrange(entriesWithNew, extendedSectionRules, rulesByPriority, null);
int i = arranged.indexOf(memberEntry);
if (i <= 0) {
return context;
}
ArrangementEntry anchorEntry = null;
if (i >= arranged.size() - 1) {
anchorEntry = nonArranged.get(nonArranged.size() - 1);
}
else {
Set<ArrangementEntry> entriesBelow = new HashSet<ArrangementEntry>();
entriesBelow.addAll(arranged.subList(i + 1, arranged.size()));
for (ArrangementEntry entry : nonArranged) {
if (entriesBelow.contains(entry)) {
break;
}
anchorEntry = entry;
}
}
if (anchorEntry == null) {
return context;
}
int offset = anchorEntry.getEndOffset() - 1 - context.getTextRange().getStartOffset();
PsiElement element = context.findElementAt(offset);
for (PsiElement e = element; e != null && e.getTextRange().getStartOffset() >= anchorEntry.getStartOffset(); e = e.getParent()) {
element = e;
}
return element;
}