Java Code Examples for com.intellij.util.containers.ContainerUtil#map2List()

The following examples show how to use com.intellij.util.containers.ContainerUtil#map2List() . 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: CodeInsightTestFixtureImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private long collectAndCheckHighlightings(final boolean checkWarnings, final boolean checkInfos, final boolean checkWeakWarnings, final VirtualFile[] files) {
  final List<Trinity<PsiFile, Editor, ExpectedHighlightingData>> datas =
          ContainerUtil.map2List(files, new Function<VirtualFile, Trinity<PsiFile, Editor, ExpectedHighlightingData>>() {
            @Override
            public Trinity<PsiFile, Editor, ExpectedHighlightingData> fun(final VirtualFile file) {
              final PsiFile psiFile = myPsiManager.findFile(file);
              Assert.assertNotNull(psiFile);
              final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(psiFile);
              Assert.assertNotNull(document);
              ExpectedHighlightingData data = new ExpectedHighlightingData(document, checkWarnings, checkWeakWarnings, checkInfos, psiFile);
              data.init();
              return Trinity.create(psiFile, createEditor(file), data);
            }
          });
  long elapsed = 0;
  for (Trinity<PsiFile, Editor, ExpectedHighlightingData> trinity : datas) {
    myEditor = trinity.second;
    myFile = trinity.first;
    elapsed += collectAndCheckHighlighting(trinity.third);
  }
  return elapsed;
}
 
Example 2
Source File: AssertEx.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static String toString(Collection<?> collection, String separator) {
  List<String> list = ContainerUtil.map2List(collection, (Function<Object, String>)String::valueOf);
  Collections.sort(list);
  StringBuilder builder = new StringBuilder();
  boolean flag = false;
  for (final String o : list) {
    if (flag) {
      builder.append(separator);
    }
    builder.append(o);
    flag = true;
  }
  return builder.toString();
}
 
Example 3
Source File: VcsTestUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<String> toAbsolute(@Nonnull Collection<String> relPaths, @Nonnull final Project project) {
  return ContainerUtil.map2List(relPaths, s -> {
    try {
      return FileUtil.toSystemIndependentName((new File(project.getBasePath() + "/" + s).getCanonicalPath()));
    }
    catch (IOException e) {
      e.printStackTrace();
      return "";
    }
  });
}
 
Example 4
Source File: VfsUtilCore.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static List<File> virtualToIoFiles(@Nonnull Collection<VirtualFile> scope) {
  return ContainerUtil.map2List(scope, new Function<VirtualFile, File>() {
    @Override
    public File fun(VirtualFile file) {
      return virtualToIoFile(file);
    }
  });
}
 
Example 5
Source File: PsiSearchHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<IdIndexEntry> getWordEntries(@Nonnull String name, final boolean caseSensitively) {
  List<String> words = StringUtil.getWordsInStringLongestFirst(name);
  if (words.isEmpty()) {
    String trimmed = name.trim();
    if (StringUtil.isNotEmpty(trimmed)) {
      words = Collections.singletonList(trimmed);
    }
  }
  if (words.isEmpty()) return Collections.emptyList();
  return ContainerUtil.map2List(words, word -> new IdIndexEntry(word, caseSensitively));
}
 
Example 6
Source File: VcsLogUiPropertiesImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static List<List<String>> getRecentGroup(Deque<UserGroup> stateField) {
  return ContainerUtil.map2List(stateField, group -> group.users);
}
 
Example 7
Source File: FileTemplateTabAsTree.java    From consulo with Apache License 2.0 4 votes vote down vote up
FileTemplateNode(FileTemplateDescriptor descriptor) {
  this(descriptor.getDisplayName(), TargetAWT.to(descriptor.getIcon()), descriptor instanceof FileTemplateGroupDescriptor
                                                          ? ContainerUtil.map2List(((FileTemplateGroupDescriptor)descriptor).getTemplates(), FileTemplateNode::new)
                                                          : Collections.<FileTemplateNode>emptyList(), descriptor instanceof FileTemplateGroupDescriptor ? null : descriptor.getFileName());
}