Java Code Examples for com.intellij.util.containers.ContainerUtil#newArrayListWithCapacity()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#newArrayListWithCapacity() .
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: HaskellStructureViewElement.java From intellij-haskforce with Apache License 2.0 | 6 votes |
/** * Populates the structure view. Uses HaskellUtil to get backing information. */ @NotNull @Override public TreeElement[] getChildren() { if (element instanceof HaskellFile) { List<PsiNamedElement> elems = HaskellUtil.findDefinitionNodes((HaskellFile) element.getContainingFile(), null); List<TreeElement> treeElems = ContainerUtil.newArrayListWithCapacity(elems.size()); for (PsiNamedElement elem : elems) { //noinspection ObjectAllocationInLoop treeElems.add(new HaskellStructureViewElement(elem)); } return treeElems.toArray(new TreeElement[treeElems.size()]); } return EMPTY_ARRAY; }
Example 2
Source File: AnsiEscapeDecoder.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private List<Pair<String, Key>> processTextChunk(@Nullable List<Pair<String, Key>> buffer, @Nonnull String text, @Nonnull Key outputType, @Nonnull ColoredTextAcceptor textAcceptor) { Key attributes = getCurrentOutputAttributes(outputType); if (textAcceptor instanceof ColoredChunksAcceptor) { if (buffer == null) { buffer = ContainerUtil.newArrayListWithCapacity(1); } buffer.add(Pair.create(text, attributes)); } else { textAcceptor.coloredTextAvailable(text, attributes); } return buffer; }
Example 3
Source File: InspectionToolRegistrar.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @TestOnly public List<InspectionToolWrapper> createTools() { ensureInitialized(); final List<InspectionToolWrapper> tools = ContainerUtil.newArrayListWithCapacity(myInspectionToolFactories.size()); final Set<Factory<InspectionToolWrapper>> broken = ContainerUtil.newHashSet(); for (final Factory<InspectionToolWrapper> factory : myInspectionToolFactories) { ProgressManager.checkCanceled(); final InspectionToolWrapper toolWrapper = factory.create(); if (toolWrapper != null && checkTool(toolWrapper) == null) { tools.add(toolWrapper); } else { broken.add(factory); } } myInspectionToolFactories.removeAll(broken); return tools; }
Example 4
Source File: AppUIUtil.java From consulo with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") public static void updateWindowIcon(@Nonnull Window window, boolean isDark) { ApplicationInfo appInfo = ApplicationInfoImpl.getInstance(); List<Image> images = ContainerUtil.newArrayListWithCapacity(2); images.add(ImageLoader.loadFromResource(appInfo.getIconUrl(), isDark)); images.add(ImageLoader.loadFromResource(appInfo.getSmallIconUrl(), isDark)); for (int i = 0; i < images.size(); i++) { Image image = images.get(i); if (image instanceof JBHiDPIScaledImage) { images.set(i, ((JBHiDPIScaledImage)image).getDelegate()); } } window.setIconImages(images); }
Example 5
Source File: HaskellChooseByNameContributor.java From intellij-haskforce with Apache License 2.0 | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); Collection<HaskellNamedElement> result = StubIndex.getElements(HaskellAllNameIndex.KEY, name, project, scope, HaskellNamedElement.class); List<NavigationItem> items = ContainerUtil.newArrayListWithCapacity(result.size()); for (HaskellNamedElement element : result) { items.add(element); } return items.toArray(new NavigationItem[items.size()]); }
Example 6
Source File: SMTestProxy.java From consulo with Apache License 2.0 | 5 votes |
public void addChild(@Nonnull SMTestProxy child) { ApplicationManager.getApplication().assertIsDispatchThread(); if (myChildren == null) { myChildren = ContainerUtil.newArrayListWithCapacity(4); } myChildren.add(child); // add printable // // add link to child's future output in correct place // actually if after this suite will obtain output // it will place it after this child and before future child addLast(child); // add child // //TODO reset children cache child.setParent(this); boolean printOwnContentOnly = this instanceof SMRootTestProxy && ((SMRootTestProxy)this).shouldPrintOwnContentOnly(); if (!printOwnContentOnly) { child.setPrinter(myPrinter); } if (myPreferredPrinter != null && child.myPreferredPrinter == null) { child.setPreferredPrinter(myPreferredPrinter); } }
Example 7
Source File: CommandLineUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static List<String> toCommandLine(@Nonnull String command, @Nonnull List<String> parameters, @Nonnull FilePathSeparator filePathSeparator) { List<String> commandLine = ContainerUtil.newArrayListWithCapacity(parameters.size() + 1); commandLine.add(FileUtilRt.toSystemDependentName(command, filePathSeparator.fileSeparator)); boolean isWindows = filePathSeparator == FilePathSeparator.WINDOWS; boolean winShell = isWindows && isWinShell(command); for (String parameter : parameters) { if (isWindows) { if (parameter.contains("\"")) { parameter = StringUtil.replace(parameter, "\"", "\\\""); } else if (parameter.isEmpty()) { parameter = "\"\""; } } if (winShell && StringUtil.containsAnyChar(parameter, WIN_SHELL_SPECIALS)) { parameter = quote(parameter, SPECIAL_QUOTE); } if (isQuoted(parameter, SPECIAL_QUOTE)) { parameter = quote(parameter.substring(1, parameter.length() - 1), '"'); } commandLine.add(parameter); } return commandLine; }