当前位置: 首页>>代码示例>>Java>>正文


Java ContainerUtil.quickSort方法代码示例

本文整理汇总了Java中com.intellij.util.containers.ContainerUtil.quickSort方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtil.quickSort方法的具体用法?Java ContainerUtil.quickSort怎么用?Java ContainerUtil.quickSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.ContainerUtil的用法示例。


在下文中一共展示了ContainerUtil.quickSort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSortedElements

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public List<RefElement> getSortedElements() {
  List<RefElement> answer;
  synchronized (myRefTable) {
    answer = new ArrayList<RefElement>(myRefTable.values());
  }
  ContainerUtil.quickSort(answer, new Comparator<RefElement>() {
    @Override
    public int compare(RefElement o1, RefElement o2) {
      VirtualFile v1 = ((RefElementImpl)o1).getVirtualFile();
      VirtualFile v2 = ((RefElementImpl)o2).getVirtualFile();

      return (v1 != null ? v1.hashCode() : 0) - (v2 != null ? v2.hashCode() : 0);
    }
  });

  return answer;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:RefManagerImpl.java

示例2: multiResolve

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public ResolveResult[] multiResolve(final boolean incompleteCode) {
  final String key = getKeyText();

  List<IProperty> properties;
  final List<PropertiesFile> propertiesFiles = getPropertiesFiles();
  if (propertiesFiles == null) {
    properties = PropertiesImplUtil.findPropertiesByKey(getElement().getProject(), key);
  }
  else {
    properties = new ArrayList<IProperty>();
    for (PropertiesFile propertiesFile : propertiesFiles) {
      properties.addAll(propertiesFile.findPropertiesByKey(key));
    }
  }
  // put default properties file first
  ContainerUtil.quickSort(properties, new Comparator<IProperty>() {
    public int compare(final IProperty o1, final IProperty o2) {
      String name1 = o1.getPropertiesFile().getName();
      String name2 = o2.getPropertiesFile().getName();
      return Comparing.compare(name1, name2);
    }
  });
  return getResolveResults(properties);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PropertyReferenceBase.java

示例3: findClasses

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
@Override
public PsiClass[] findClasses(@NotNull String qName, @NotNull final GlobalSearchScope scope) {
  final Collection<PsiClass> classes = JavaFullClassNameIndex.getInstance().get(qName.hashCode(), myManager.getProject(), scope);
  if (classes.isEmpty()) return PsiClass.EMPTY_ARRAY;
  List<PsiClass> result = new ArrayList<PsiClass>(classes.size());
  for (PsiClass aClass : classes) {
    final String qualifiedName = aClass.getQualifiedName();
    if (qualifiedName == null || !qualifiedName.equals(qName)) continue;

    PsiUtilCore.ensureValid(aClass);
    PsiFile file = aClass.getContainingFile();
    if (file == null) {
      throw new AssertionError("No file for class: " + aClass + " of " + aClass.getClass());
    }

    VirtualFile vFile = file.getVirtualFile();
    if (!hasAcceptablePackage(vFile)) continue;

    result.add(aClass);
  }

  int count = result.size();
  if (count == 0) return PsiClass.EMPTY_ARRAY;
  if (count == 1) return new PsiClass[] {result.get(0)};

  ContainerUtil.quickSort(result, new Comparator<PsiClass>() {
    @Override
    public int compare(PsiClass o1, PsiClass o2) {
      return scope.compare(o2.getContainingFile().getVirtualFile(), o1.getContainingFile().getVirtualFile());
    }
  });

  return result.toArray(new PsiClass[count]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:JavaFileManagerImpl.java

示例4: getClasses

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
@NotNull
public PsiClass[] getClasses(@Nullable String shortName, @NotNull PsiPackage psiPackage, @NotNull final GlobalSearchScope scope) {
  List<PsiClass> list = null;
  String packageName = psiPackage.getQualifiedName();
  for (PsiDirectory dir : psiPackage.getDirectories(scope)) {
    PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(dir);
    if (classes.length == 0) continue;
    if (list == null) list = new ArrayList<PsiClass>();
    for (PsiClass aClass : classes) {
      // class file can be located in wrong place inside file system
      String qualifiedName = aClass.getQualifiedName();
      if (qualifiedName != null) qualifiedName = StringUtil.getPackageName(qualifiedName);
      if (Comparing.strEqual(qualifiedName, packageName)) {
        if (shortName == null || shortName.equals(aClass.getName())) list.add(aClass);
      }
    }
  }
  if (list == null) {
    return PsiClass.EMPTY_ARRAY;
  }

  if (list.size() > 1) {
    ContainerUtil.quickSort(list, new Comparator<PsiClass>() {
      @Override
      public int compare(PsiClass o1, PsiClass o2) {
        VirtualFile file1 = PsiUtilCore.getVirtualFile(o1);
        VirtualFile file2 = PsiUtilCore.getVirtualFile(o2);
        return file1 == null ? file2 == null ? 0 : -1 : file2 == null ? 1 : scope.compare(file2, file1);
      }
    });
  }

  return list.toArray(new PsiClass[list.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PsiElementFinderImpl.java

示例5: getPastFileEndBackground

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
public Color getPastFileEndBackground() {
  boolean isInCaretRow = myEditor.getCaretModel().getLogicalPosition().line >= myDocument.getLineCount() - 1;

  Color caret = isInCaretRow && myCaretRowAttributes != null ? myCaretRowAttributes.getBackgroundColor() : null;

  ContainerUtil.quickSort(myCurrentHighlighters, LayerComparator.INSTANCE);

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < myCurrentHighlighters.size(); i++) {
    RangeHighlighterEx highlighter = myCurrentHighlighters.get(i);
    if (caret != null && highlighter.getLayer() < HighlighterLayer.CARET_ROW) {
      return caret;
    }

    if (highlighter.getTargetArea() != HighlighterTargetArea.LINES_IN_RANGE
        || myDocument.getLineNumber(highlighter.getEndOffset()) < myDocument.getLineCount() - 1) {
      continue;
    }

    TextAttributes textAttributes = highlighter.getTextAttributes();
    if (textAttributes != null) {
      Color backgroundColor = textAttributes.getBackgroundColor();
      if (backgroundColor != null) return backgroundColor;
    }
  }

  return caret;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:IterationState.java

示例6: sortById

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static void sortById(@NotNull List<TextEditorHighlightingPass> result) {
  ContainerUtil.quickSort(result, new Comparator<TextEditorHighlightingPass>() {
    @Override
    public int compare(@NotNull TextEditorHighlightingPass o1, @NotNull TextEditorHighlightingPass o2) {
      return o1.getId() - o2.getId();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PassExecutorService.java

示例7: calcTooltipRenderer

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public TooltipRenderer calcTooltipRenderer(@NotNull final Collection<RangeHighlighter> highlighters) {
  LineTooltipRenderer bigRenderer = null;
  List<HighlightInfo> infos = new SmartList<HighlightInfo>();
  Collection<String> tooltips = new THashSet<String>(); //do not show same tooltip twice
  for (RangeHighlighter marker : highlighters) {
    final Object tooltipObject = marker.getErrorStripeTooltip();
    if (tooltipObject == null) continue;
    if (tooltipObject instanceof HighlightInfo) {
      HighlightInfo info = (HighlightInfo)tooltipObject;
      if (info.getToolTip() != null && tooltips.add(info.getToolTip())) {
        infos.add(info);
      }
    }
    else {
      final String text = tooltipObject.toString();
      if (tooltips.add(text)) {
        if (bigRenderer == null) {
          bigRenderer = new MyRenderer(text, new Object[] {highlighters});
        }
        else {
          bigRenderer.addBelow(text);
        }
      }
    }
  }
  if (!infos.isEmpty()) {
    // show errors first
    ContainerUtil.quickSort(infos, new Comparator<HighlightInfo>() {
      @Override
      public int compare(final HighlightInfo o1, final HighlightInfo o2) {
        int i = SeverityRegistrar.getSeverityRegistrar(myProject).compare(o2.getSeverity(), o1.getSeverity());
        if (i != 0) return i;
        return o1.getToolTip().compareTo(o2.getToolTip());
      }
    });
    final HighlightInfoComposite composite = new HighlightInfoComposite(infos);
    if (bigRenderer == null) {
      bigRenderer = new MyRenderer(UIUtil.convertSpace2Nbsp(composite.getToolTip()), new Object[] {highlighters});
    }
    else {
      final LineTooltipRenderer renderer = new MyRenderer(UIUtil.convertSpace2Nbsp(composite.getToolTip()), new Object[] {highlighters});
      renderer.addBelow(bigRenderer.getText());
      bigRenderer = renderer;
    }
  }
  return bigRenderer;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:DaemonTooltipRendererProvider.java


注:本文中的com.intellij.util.containers.ContainerUtil.quickSort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。