本文整理汇总了Java中com.intellij.util.containers.ContainerUtil.sort方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtil.sort方法的具体用法?Java ContainerUtil.sort怎么用?Java ContainerUtil.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.containers.ContainerUtil
的用法示例。
在下文中一共展示了ContainerUtil.sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveSelectedRows
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static void moveSelectedRows(@NotNull final SimpleTree tree, final int direction) {
final TreePath[] selectionPaths = tree.getSelectionPaths();
if (selectionPaths == null) return;
ContainerUtil.sort(selectionPaths, new Comparator<TreePath>() {
@Override
public int compare(TreePath o1, TreePath o2) {
return -direction * compare(tree.getRowForPath(o1), tree.getRowForPath(o2));
}
private int compare(int x, int y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
});
for (TreePath selectionPath : selectionPaths) {
final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)selectionPath.getLastPathComponent();
final DefaultMutableTreeNode parent = (DefaultMutableTreeNode)treeNode.getParent();
final int idx = parent.getIndex(treeNode);
((DefaultTreeModel)tree.getModel()).removeNodeFromParent(treeNode);
((DefaultTreeModel)tree.getModel()).insertNodeInto(treeNode, parent, idx + direction);
}
tree.addSelectionPaths(selectionPaths);
}
示例2: getRevisionNumbers
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
public List<VcsRevisionNumber> getRevisionNumbers(@NotNull DataProvider dataProvider) {
VcsRevisionNumber revisionNumber = VcsDataKeys.VCS_REVISION_NUMBER.getData(dataProvider);
if (revisionNumber != null) {
return Collections.singletonList(revisionNumber);
}
ChangeList[] changeLists = VcsDataKeys.CHANGE_LISTS.getData(dataProvider);
if (changeLists != null && changeLists.length > 0) {
List<CommittedChangeList> committedChangeLists = ContainerUtil.findAll(changeLists, CommittedChangeList.class);
if (!committedChangeLists.isEmpty()) {
ContainerUtil.sort(committedChangeLists, CommittedChangeListByDateComparator.DESCENDING);
return ContainerUtil.mapNotNull(committedChangeLists, CommittedChangeListToRevisionNumberFunction.INSTANCE);
}
}
VcsFileRevision[] fileRevisions = VcsDataKeys.VCS_FILE_REVISIONS.getData(dataProvider);
if (fileRevisions != null && fileRevisions.length > 0) {
return ContainerUtil.mapNotNull(fileRevisions, FileRevisionToRevisionNumberFunction.INSTANCE);
}
return null;
}
示例3: bind
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public void bind(@NotNull Project project, @NotNull List<GradleEditorSourceBinding> sourceBindings) {
myProjectRef = new WeakReference<Project>(project);
ImmutableListMultimap<VirtualFile, GradleEditorSourceBinding> byFile = Multimaps.index(sourceBindings, GROUPER);
List<VirtualFile> orderedFiles = Lists.newArrayList(byFile.keySet());
ContainerUtil.sort(orderedFiles, FILES_COMPARATOR);
for (VirtualFile file : orderedFiles) {
ImmutableList<GradleEditorSourceBinding> list = byFile.get(file);
List<RangeMarker> rangeMarkers = Lists.newArrayList();
for (GradleEditorSourceBinding descriptor : list) {
rangeMarkers.add(descriptor.getRangeMarker());
}
if (!rangeMarkers.isEmpty()) {
ContainerUtil.sort(rangeMarkers, RANGE_COMPARATOR);
String name = getRepresentativeName(project, file);
mySourceBindings.put(name, rangeMarkers);
myFilesByName.put(name, file);
}
}
}
示例4: runCommit
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private CommitInfo[] runCommit(@NotNull List<File> paths, @NotNull String message) throws VcsException {
if (ContainerUtil.isEmpty(paths)) return new CommitInfo[]{CommitInfo.EMPTY};
Command command = newCommand(SvnCommandName.ci);
command.put(Depth.EMPTY);
command.put("-m", message);
// TODO: seems that sort is not necessary here
ContainerUtil.sort(paths);
command.setTargets(paths);
IdeaCommitHandler handler = new IdeaCommitHandler(ProgressManager.getInstance().getProgressIndicator());
CmdCheckinClient.CommandListener listener = new CommandListener(handler);
listener.setBaseDirectory(CommandUtil.requireExistingParent(paths.get(0)));
execute(myVcs, SvnTarget.fromFile(paths.get(0)), null, command, listener);
listener.throwExceptionIfOccurred();
long revision = validateRevisionNumber(listener.getCommittedRevision());
return new CommitInfo[]{new CommitInfo.Builder().setRevision(revision).build()};
}
示例5: getOverriddenMethods
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public List<JavaArrangementOverriddenMethodsInfo> getOverriddenMethods() {
List<JavaArrangementOverriddenMethodsInfo> result = new ArrayList<JavaArrangementOverriddenMethodsInfo>();
final TObjectIntHashMap<PsiMethod> weights = new TObjectIntHashMap<PsiMethod>();
Comparator<Pair<PsiMethod, PsiMethod>> comparator = new Comparator<Pair<PsiMethod, PsiMethod>>() {
@Override
public int compare(Pair<PsiMethod, PsiMethod> o1, Pair<PsiMethod, PsiMethod> o2) {
return weights.get(o1.first) - weights.get(o2.first);
}
};
for (Map.Entry<PsiClass, List<Pair<PsiMethod, PsiMethod>>> entry : myOverriddenMethods.entrySet()) {
JavaArrangementOverriddenMethodsInfo info = new JavaArrangementOverriddenMethodsInfo(entry.getKey().getName());
weights.clear();
int i = 0;
for (PsiMethod method : entry.getKey().getMethods()) {
weights.put(method, i++);
}
ContainerUtil.sort(entry.getValue(), comparator);
for (Pair<PsiMethod, PsiMethod> pair : entry.getValue()) {
JavaElementArrangementEntry overridingMethodEntry = myMethodEntriesMap.get(pair.second);
if (overridingMethodEntry != null) {
info.addMethodEntry(overridingMethodEntry);
}
}
if (!info.getMethodEntries().isEmpty()) {
result.add(info);
}
}
return result;
}
示例6: fixUnderdoneEdges
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void fixUnderdoneEdges() {
List<CommitId> commitIds = ContainerUtil.newArrayList(upAdjacentNodes.keySet());
ContainerUtil.sort(commitIds, new Comparator<CommitId>() {
@Override
public int compare(@NotNull CommitId o1, @NotNull CommitId o2) {
return Collections.min(upAdjacentNodes.get(o1)) - Collections.min(upAdjacentNodes.get(o2));
}
});
for (CommitId notLoadCommit : commitIds) {
int notLoadId = myNotLoadCommitToId.fun(notLoadCommit);
for (int upNodeIndex : upAdjacentNodes.get(notLoadCommit)) {
fixUnderdoneEdgeForNotLoadCommit(upNodeIndex, notLoadId);
}
}
}
示例7: createCurrentSeverityNames
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private List<String> createCurrentSeverityNames() {
List<String> list = new ArrayList<String>();
list.addAll(STANDARD_SEVERITIES.keySet());
list.addAll(myMap.keySet());
ContainerUtil.sort(list);
return list;
}
示例8: getDefaultOrder
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private List<HighlightSeverity> getDefaultOrder() {
Collection<SeverityBasedTextAttributes> values = myMap.values();
List<HighlightSeverity> order = new ArrayList<HighlightSeverity>(STANDARD_SEVERITIES.size() + values.size());
for (HighlightInfoType type : STANDARD_SEVERITIES.values()) {
order.add(type.getSeverity(null));
}
for (SeverityBasedTextAttributes attributes : values) {
order.add(attributes.getSeverity());
}
ContainerUtil.sort(order);
return order;
}
示例9: getRulesSortedByPriority
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的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;
}
示例10: getRulesSortedByPriority
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的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;
}
示例11: visit
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
Element composite = new Element(COMPOSITE_CONDITION_NAME);
register(composite);
parent = composite;
List<ArrangementMatchCondition> operands = ContainerUtilRt.newArrayList(condition.getOperands());
ContainerUtil.sort(operands, CONDITION_COMPARATOR);
for (ArrangementMatchCondition c : operands) {
c.invite(this);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:DefaultArrangementEntryMatcherSerializer.java
示例12: getStubbedRoots
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
/** Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()} */
@NotNull
public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@NotNull FileViewProvider viewProvider) {
final List<Trinity<Language, IStubFileElementType, PsiFile>> roots =
new SmartList<Trinity<Language, IStubFileElementType, PsiFile>>();
final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot();
for (Language language : viewProvider.getLanguages()) {
final PsiFile file = viewProvider.getPsi(language);
if (file instanceof PsiFileImpl) {
final IElementType type = ((PsiFileImpl)file).getElementTypeForStubBuilder();
if (type != null) {
roots.add(Trinity.create(language, (IStubFileElementType)type, file));
}
}
}
ContainerUtil.sort(roots, new Comparator<Trinity<Language, IStubFileElementType, PsiFile>>() {
@Override
public int compare(Trinity<Language, IStubFileElementType, PsiFile> o1, Trinity<Language, IStubFileElementType, PsiFile> o2) {
if (o1.third == stubBindingRoot) return o2.third == stubBindingRoot ? 0 : -1;
else if (o2.third == stubBindingRoot) return 1;
else return StringUtil.compare(o1.first.getID(), o2.first.getID(), false);
}
});
return ContainerUtil.map(roots, new Function<Trinity<Language, IStubFileElementType, PsiFile>, Pair<IStubFileElementType, PsiFile>>() {
@Override
public Pair<IStubFileElementType, PsiFile> fun(Trinity<Language, IStubFileElementType, PsiFile> trinity) {
return Pair.create(trinity.second, trinity.third);
}
});
}
示例13: sortByPresentation
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static List<LookupElement> sortByPresentation(Iterable<LookupElement> source, LookupImpl lookup) {
ArrayList<LookupElement> startMatches = ContainerUtil.newArrayList();
ArrayList<LookupElement> middleMatches = ContainerUtil.newArrayList();
for (LookupElement element : source) {
(CompletionServiceImpl.isStartMatch(element, lookup) ? startMatches : middleMatches).add(element);
}
ContainerUtil.sort(startMatches, BY_PRESENTATION_COMPARATOR);
ContainerUtil.sort(middleMatches, BY_PRESENTATION_COMPARATOR);
startMatches.addAll(middleMatches);
return startMatches;
}
示例14: PostfixTemplatesConfigurable
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public PostfixTemplatesConfigurable() {
PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
if (settings == null) {
throw new RuntimeException("Can't retrieve postfix template settings");
}
myTemplatesSettings = settings;
LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(LanguagePostfixTemplate.EP_NAME).getExtensions();
templateMultiMap = MultiMap.create();
for (LanguageExtensionPoint extension : extensions) {
List<PostfixTemplate> postfixTemplates =
ContainerUtil.newArrayList(((PostfixTemplateProvider)extension.getInstance()).getTemplates());
if (postfixTemplates.isEmpty()) {
continue;
}
ContainerUtil.sort(postfixTemplates, TEMPLATE_COMPARATOR);
templateMultiMap.putValues(extension.getKey(), postfixTemplates);
}
myPostfixTemplatesEnabled.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updateComponents();
}
});
myShortcutComboBox.addItem(TAB);
myShortcutComboBox.addItem(SPACE);
myShortcutComboBox.addItem(ENTER);
myDescriptionPanel.setLayout(new BorderLayout());
}
示例15: getScripts
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private static List<VirtualFile> getScripts() {
VirtualFile root = getScriptsRootDirectory();
if (root == null) return ContainerUtil.emptyList();
VfsUtil.markDirtyAndRefresh(false, true, true, root);
List<VirtualFile> scripts = VfsUtil.collectChildrenRecursively(root);
scripts = ContainerUtil.filter(scripts, ExtensionsRootType.regularFileFilter());
ContainerUtil.sort(scripts, new FileNameComparator());
return scripts;
}