Java 类com.intellij.util.containers.SortedList 实例源码

项目:AppleScript-IDEA    文件:AppleScriptResolveUtil.java   
@NotNull
public static SortedList<PsiElement> getTellStatementResolveScope(PsiElement myElement) {
  SortedList<PsiElement> resultList = new SortedList<>((e1, e2) -> e2.getTextOffset() - e1.getTextOffset());
  PsiElement tellStatement = myElement;
  while (tellStatement != null) {
    tellStatement = tellStatement.getParent();
    if (tellStatement instanceof AppleScriptTellSimpleStatement || tellStatement instanceof AppleScriptTellCompoundStatement) {
      resultList.add(tellStatement);
    }
  }
  return resultList;
}
项目:AppleScript-IDEA    文件:AppleScriptPsiImplUtil.java   
public static List<String> getApplicationNameForElementInsideTellStatement(PsiElement element) {
  SortedList<PsiElement> resolveScope = AppleScriptResolveUtil.getTellStatementResolveScope(element);
  List<String> result = new ArrayList<>();
  for (PsiElement tellStatement : resolveScope) {
    String appRef = findApplicationNameFromTellStatement(tellStatement);
    if (!StringUtil.isEmpty(appRef)) {
      result.add(appRef);
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:DTree.java   
@NotNull
public Collection<DTree> getChildren() {
  init();
  if (myChildrenList == null) {
    myChildrenList = new SortedList<DTree>(COMPARATOR);
    myChildrenList.addAll(myChildren.values());
  }
  return myChildrenList;
}
项目:intellij-ce-playground    文件:RatedResolveResult.java   
public static List<RatedResolveResult> sorted(List<RatedResolveResult> targets) {
  if (targets.size() == 1) {
    return targets;
  }
  List<RatedResolveResult> ret = new SortedList<RatedResolveResult>(new Comparator<RatedResolveResult>() {
    public int compare(final RatedResolveResult one, final RatedResolveResult another) {
      return another.getRate() - one.getRate();
    }
  });
  ret.addAll(targets);
  return ret;
}
项目:intellij-ce-playground    文件:CaptureRootNode.java   
public CaptureRootNode() {
  myTypes = new SortedList<CaptureTypeNode>(new Comparator<CaptureTypeNode>() {
    @Override
    public int compare(CaptureTypeNode a, CaptureTypeNode b) {
      return a.getName().compareToIgnoreCase(b.getName());
    }
  });
}
项目:intellij-ce-playground    文件:CaptureTypeNode.java   
public CaptureTypeNode(CaptureType type) {
  myType = type;
  myCaptureNodes = new SortedList<CaptureNode>(new Comparator<CaptureNode>() {
    @Override
    public int compare(CaptureNode a, CaptureNode b) {
      return a.getName().compareToIgnoreCase(b.getName());
    }
  });

  getTemplatePresentation().addText(type.getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
  setIcon(AllIcons.Modules.SourceFolder);
}
项目:intellij-ce-playground    文件:DescriptionTypeRelatedItemLineMarkerProvider.java   
private static void addBeforeAfterTemplateFilesGutterIcon(PsiElement highlightingElement,
                                                          PsiDirectory descriptionDirectory,
                                                          Collection<? super RelatedItemLineMarkerInfo> result) {
  final List<PsiFile> templateFiles = new SortedList<PsiFile>(new Comparator<PsiFile>() {
    @Override
    public int compare(PsiFile o1, PsiFile o2) {
      return o1.getName().compareTo(o2.getName());
    }
  });
  for (PsiFile file : descriptionDirectory.getFiles()) {
    final String fileName = file.getName();
    if (fileName.endsWith(".template")) {
      if (fileName.startsWith("after.") ||
          fileName.startsWith("before.")) {
        templateFiles.add(file);
      }
    }
  }
  if (templateFiles.isEmpty()) return;

  final RelatedItemLineMarkerInfo<PsiElement> info = NavigationGutterIconBuilder
    .create(AllIcons.Actions.Diff, CONVERTER, RELATED_ITEM_PROVIDER)
    .setTargets(templateFiles)
    .setPopupTitle("Select Template")
    .setTooltipText("Before/After Templates")
    .setAlignment(GutterIconRenderer.Alignment.RIGHT)
    .createLineMarkerInfo(highlightingElement);
  result.add(info);
}
项目:tools-idea    文件:XValueContainerNode.java   
@Override
public void addChildren(@NotNull final XValueChildrenProvider children, final boolean last) {
  DebuggerUIUtil.invokeLater(new Runnable() {
    @Override
    public void run() {
      if (myValueChildren == null) {
        if (!isAlreadySorted() && XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
          myValueChildren = new SortedList<XValueNodeImpl>(XValueNodeImpl.COMPARATOR);
        }
        else {
          myValueChildren = new ArrayList<XValueNodeImpl>();
        }
      }
      List<XValueContainerNode<?>> newChildren = new SmartList<XValueContainerNode<?>>();
      for (int i = 0; i < children.size(); i++) {
        XValueNodeImpl node = new XValueNodeImpl(myTree, XValueContainerNode.this, children.getName(i), children.getValue(i));
        myValueChildren.add(node);
        newChildren.add(node);
      }
      myCachedAllChildren = null;
      fireNodesInserted(newChildren);
      if (last) {
        final int[] ints = getNodesIndices(myTemporaryMessageChildren);
        final TreeNode[] removed = getChildNodes(ints);
        myCachedAllChildren = null;
        myTemporaryMessageChildren = null;
        fireNodesRemoved(ints, removed);
      }
      myTree.childrenLoaded(XValueContainerNode.this, newChildren, last);
    }
  });
}
项目:tools-idea    文件:AnnotateToggleAction.java   
@Nullable
private static Map<String, Integer> computeLineNumbers(FileAnnotation fileAnnotation) {
  final SortedList<VcsFileRevision> revisions = new SortedList<VcsFileRevision>(new Comparator<VcsFileRevision>() {
    @Override
    public int compare(VcsFileRevision o1, VcsFileRevision o2) {
      try {
        final int result = o1.getRevisionDate().compareTo(o2.getRevisionDate());
        return result != 0 ? result : o1.getRevisionNumber().compareTo(o2.getRevisionNumber());
      }
      catch (Exception e) {
        return 0;
      }
    }
  });
  final Map<String, Integer> numbers = new HashMap<String, Integer>();
  final List<VcsFileRevision> fileRevisionList = fileAnnotation.getRevisions();
  if (fileRevisionList != null) {
    revisions.addAll(fileRevisionList);
    for (VcsFileRevision revision : fileRevisionList) {
      final String revNumber = revision.getRevisionNumber().asString();
      if (!numbers.containsKey(revNumber)) {
        final int num = revisions.indexOf(revision);
        if (num != -1) {
          numbers.put(revNumber, num + 1);
        }
      }
    }
  }
  return numbers.size() < 2 ? null : numbers;
}
项目:tools-idea    文件:DTree.java   
@NotNull
public Collection<DTree> getChildren() {
  init();
  if (myChildrenList == null) {
    myChildrenList = new SortedList<DTree>(COMPARATOR);
    myChildrenList.addAll(myChildren.values());
  }
  return myChildrenList;
}
项目:lombok-intellij-plugin    文件:AbstractLombokParsingTestCase.java   
private String[] toList(PsiMethod[] beforeMethods) {
  SortedList<String> result = new SortedList<String>(String.CASE_INSENSITIVE_ORDER);
  for (PsiMethod method : beforeMethods) {
    result.add(method.getName());
  }
  return result.toArray(new String[result.size()]);
}
项目:consulo    文件:DTree.java   
@Nonnull
public Collection<DTree> getChildren() {
  init();
  if (myChildrenList == null) {
    myChildrenList = new SortedList<DTree>(COMPARATOR);
    myChildrenList.addAll(myChildren.values());
  }
  return myChildrenList;
}
项目:intellij-ce-playground    文件:ToolbarDecoratorActionPromoter.java   
@Override
public List<AnAction> promote(List<AnAction> actions, DataContext context) {
  final SortedList<AnAction> result = new SortedList<AnAction>(ACTION_BUTTONS_SORTER);
  result.addAll(actions);
  return result;
}
项目:intellij-ce-playground    文件:XValueContainerNode.java   
@Override
public void addChildren(@NotNull final XValueChildrenList children, final boolean last) {
  if (myObsolete) return;
  invokeNodeUpdate(new Runnable() {
    @Override
    public void run() {
      if (myObsolete) return;
      List<XValueContainerNode<?>> newChildren;
      if (children.size() > 0) {
        newChildren = new ArrayList<XValueContainerNode<?>>(children.size());
        if (myValueChildren == null) {
          if (!myAlreadySorted && XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
            myValueChildren = new SortedList<XValueNodeImpl>(XValueNodeImpl.COMPARATOR);
          }
          else {
            myValueChildren = new ArrayList<XValueNodeImpl>(children.size());
          }
        }
        final InlineDebuggerHelper inlineHelper = getTree().getEditorsProvider().getInlineDebuggerHelper();
        for (int i = 0; i < children.size(); i++) {
          XValueNodeImpl node = new XValueNodeImpl(myTree, XValueContainerNode.this, children.getName(i), children.getValue(i));
          myValueChildren.add(node);
          newChildren.add(node);

          if (Registry.is("ide.debugger.inline") && inlineHelper.shouldEvaluateChildrenByDefault(node) && isUseGetChildrenHack(myTree)) { //todo[kb]: try to generify this dirty hack
            node.getChildren();
          }
        }
      }
      else {
        newChildren = new SmartList<XValueContainerNode<?>>();
        if (myValueChildren == null) {
          myValueChildren = last ? Collections.<XValueNodeImpl>emptyList() : new SmartList<XValueNodeImpl>();
        }
      }

      myTopGroups = createGroupNodes(children.getTopGroups(), myTopGroups, newChildren);
      myBottomGroups = createGroupNodes(children.getBottomGroups(), myBottomGroups, newChildren);
      myCachedAllChildren = null;
      fireNodesInserted(newChildren);
      if (last && myTemporaryMessageChildren != null) {
        final int[] ints = getNodesIndices(myTemporaryMessageChildren);
        final TreeNode[] removed = myTemporaryMessageChildren.toArray(new TreeNode[myTemporaryMessageChildren.size()]);
        myCachedAllChildren = null;
        myTemporaryMessageChildren = null;
        fireNodesRemoved(ints, removed);
      }
      myTree.childrenLoaded(XValueContainerNode.this, newChildren, last);
    }
  });
}
项目:teamcity-dottrace    文件:HistoryImpl.java   
@Override
@NotNull
public Iterable<HistoryElement> getElements(@NotNull final List<SFinishedBuild> builds) {
  final SortedList<SFinishedBuild> sortedBuilds = new SortedList<SFinishedBuild>(new Comparator<SFinishedBuild>() {
    @Override
    public int compare(final SFinishedBuild o1, final SFinishedBuild o2) {
      return o1.getFinishDate().compareTo(o2.getFinishDate());
    }
  });

  sortedBuilds.addAll(builds);

  return new Iterable<HistoryElement>() {
    @Override
    public Iterator<HistoryElement> iterator() {
      return new Iterator<HistoryElement>() {
        private int index = 0;

        @Override
        public boolean hasNext() {
          return index < sortedBuilds.size();
        }

        @Override
        public HistoryElement next() {
          final int curIndex = index++;
          return new HistoryElement() {
            @Nullable
            @Override
            public BigDecimal tryGetValue(@NotNull final String key) {
              return myStorage.getValues(sortedBuilds.get(curIndex)).get(key);
            }
          };
        }

        @Override
        public void remove() {
          throw new UnsupportedOperationException();
        }
      };
    }
  };
}
项目:consulo    文件:ToolbarDecoratorActionPromoter.java   
@Override
public List<AnAction> promote(List<AnAction> actions, DataContext context) {
  final SortedList<AnAction> result = new SortedList<AnAction>(ACTION_BUTTONS_SORTER);
  result.addAll(actions);
  return result;
}
项目:consulo    文件:XValueContainerNode.java   
@Override
public void addChildren(@Nonnull final XValueChildrenList children, final boolean last) {
  if (myObsolete) return;
  invokeNodeUpdate(() -> {
    if (myObsolete) return;
    List<XValueContainerNode<?>> newChildren;
    if (children.size() > 0) {
      newChildren = new ArrayList<>(children.size());
      if (myValueChildren == null) {
        if (!myAlreadySorted && XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
          myValueChildren = new SortedList<>(XValueNodeImpl.COMPARATOR);
        }
        else {
          myValueChildren = new ArrayList<>(children.size());
        }
      }
      boolean valuesInline = XDebuggerSettingsManager.getInstance().getDataViewSettings().isShowValuesInline();
      InlineDebuggerHelper inlineHelper = getTree().getEditorsProvider().getInlineDebuggerHelper();
      for (int i = 0; i < children.size(); i++) {
        XValueNodeImpl node = new XValueNodeImpl(myTree, this, children.getName(i), children.getValue(i));
        myValueChildren.add(node);
        newChildren.add(node);

        if (valuesInline && inlineHelper.shouldEvaluateChildrenByDefault(node) && isUseGetChildrenHack(myTree)) { //todo[kb]: try to generify this dirty hack
          node.getChildren();
        }
      }
    }
    else {
      newChildren = new SmartList<>();
      if (myValueChildren == null) {
        myValueChildren = new SmartList<>();
      }
    }

    myTopGroups = createGroupNodes(children.getTopGroups(), myTopGroups, newChildren);
    myBottomGroups = createGroupNodes(children.getBottomGroups(), myBottomGroups, newChildren);
    myCachedAllChildren = null;
    fireNodesInserted(newChildren);
    if (last && myTemporaryMessageChildren != null) {
      final int[] ints = getNodesIndices(myTemporaryMessageChildren);
      final TreeNode[] removed = myTemporaryMessageChildren.toArray(new TreeNode[myTemporaryMessageChildren.size()]);
      myCachedAllChildren = null;
      myTemporaryMessageChildren = null;
      fireNodesRemoved(ints, removed);
    }
    myTree.childrenLoaded(this, newChildren, last);
  });
}