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


Java ContainerUtil.newArrayListWithCapacity方法代码示例

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


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

示例1: registerInjectionSimple

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public static boolean registerInjectionSimple(@NotNull PsiLanguageInjectionHost host,
                                              @NotNull BaseInjection injection,
                                              @Nullable LanguageInjectionSupport support,
                                              @NotNull MultiHostRegistrar registrar) {
  Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
  if (language == null) return false;

  InjectedLanguage injectedLanguage =
    InjectedLanguage.create(injection.getInjectedLanguageId(), injection.getPrefix(), injection.getSuffix(), false);

  List<TextRange> ranges = injection.getInjectedArea(host);
  List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list = ContainerUtil.newArrayListWithCapacity(ranges.size());

  for (TextRange range : ranges) {
    list.add(Trinity.create(host, injectedLanguage, range));
  }
  //if (host.getChildren().length > 0) {
  //  host.putUserData(LanguageInjectionSupport.HAS_UNPARSABLE_FRAGMENTS, Boolean.TRUE);
  //}
  registerInjection(language, list, host.getContainingFile(), registrar);
  if (support != null) {
    registerSupport(support, true, registrar);
  }
  return !ranges.isEmpty();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:InjectorUtils.java

示例2: getVariants

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
protected List<LookupElement> getVariants(@NotNull final DataNode<ProjectData> projectDataNode, @NotNull final String modulePath) {
  final DataNode<ModuleData> moduleDataNode = findModuleDataNode(projectDataNode, modulePath);
  if (moduleDataNode == null) {
    return Collections.emptyList();
  }

  final ModuleData moduleData = moduleDataNode.getData();
  final boolean isRoot = projectDataNode.getData().getLinkedExternalProjectPath().equals(moduleData.getLinkedExternalProjectPath());
  final Collection<DataNode<TaskData>> tasks = ExternalSystemApiUtil.getChildren(moduleDataNode, ProjectKeys.TASK);
  List<LookupElement> elements = ContainerUtil.newArrayListWithCapacity(tasks.size());

  for (DataNode<TaskData> taskDataNode : tasks) {
    final TaskData taskData = taskDataNode.getData();
    elements.add(LookupElementBuilder.create(taskData.getName()).withIcon(ExternalSystemIcons.Task));
    if (!taskData.isInherited()) {
      elements.add(LookupElementBuilder.create((isRoot ? ':' : moduleData.getId() + ':') + taskData.getName())
                     .withIcon(ExternalSystemIcons.Task));
    }
  }
  return elements;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GradleArgumentsCompletionProvider.java

示例3: processTextChunk

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
private List<Pair<String, Key>> processTextChunk(@Nullable List<Pair<String, Key>> buffer,
                                                 @NotNull String text,
                                                 @NotNull Key outputType,
                                                 @NotNull 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AnsiEscapeDecoder.java

示例4: processAbbreviations

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private boolean processAbbreviations(final String pattern, Processor<MatchedValue> consumer, DataContext context) {
  List<String> actions = AbbreviationManager.getInstance().findActions(pattern);
  if (actions.isEmpty()) return true;
  List<ActionWrapper> wrappers = ContainerUtil.newArrayListWithCapacity(actions.size());
  for (String actionId : actions) {
    AnAction action = myActionManager.getAction(actionId);
    wrappers.add(new ActionWrapper(action, myModel.myActionGroups.get(action), MatchMode.NAME, context));
  }
  return ContainerUtil.process(ContainerUtil.map(wrappers, new Function<ActionWrapper, MatchedValue>() {
    @Override
    public MatchedValue fun(@NotNull ActionWrapper w) {
      return new MatchedValue(w, pattern) {
        @Nullable
        @Override
        public String getValueText() {
          return pattern;
        }
      };
    }
  }), consumer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GotoActionItemProvider.java

示例5: buildIdTree

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private static Map<String, List<String>> buildIdTree(@NotNull Map<String, ConfigurableWrapper> idToConfigurable,
                                                     @NotNull List<String> idsInEpOrder) {
  Map<String, List<String>> tree = ContainerUtil.newHashMap();
  for (String id : idsInEpOrder) {
    ConfigurableWrapper wrapper = idToConfigurable.get(id);
    String parentId = wrapper.getParentId();
    if (parentId != null) {
      ConfigurableWrapper parent = idToConfigurable.get(parentId);
      if (parent == null) {
        LOG.warn("Can't find parent for " + parentId + " (" + wrapper + ")");
        continue;
      }
      List<String> children = tree.get(parentId);
      if (children == null) {
        children = ContainerUtil.newArrayListWithCapacity(5);
        tree.put(parentId, children);
      }
      children.add(id);
    }
  }
  return tree;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ConfigurableExtensionPointUtil.java

示例6: getChosenFiles

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private static List<VirtualFile> getChosenFiles(final List<String> paths) {
  if (ContainerUtil.isEmpty(paths)) {
    return Collections.emptyList();
  }

  final LocalFileSystem fs = LocalFileSystem.getInstance();
  final List<VirtualFile> files = ContainerUtil.newArrayListWithCapacity(paths.size());
  for (String path : paths) {
    final String vfsPath = FileUtil.toSystemIndependentName(path);
    final VirtualFile file = fs.refreshAndFindFileByPath(vfsPath);
    if (file != null && file.isValid()) {
      files.add(file);
    }
  }

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

示例7: getAppIconImages

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@SuppressWarnings({"UnnecessaryFullyQualifiedName", "deprecation"})
private static List<Image> getAppIconImages() {
  ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
  List<Image> images = ContainerUtil.newArrayListWithCapacity(3);

  if (SystemInfo.isXWindow) {
    String bigIconUrl = appInfo.getBigIconUrl();
    if (bigIconUrl != null) {
      images.add(com.intellij.util.ImageLoader.loadFromResource(bigIconUrl));
    }
  }

  images.add(com.intellij.util.ImageLoader.loadFromResource(appInfo.getIconUrl()));
  images.add(com.intellij.util.ImageLoader.loadFromResource(appInfo.getSmallIconUrl()));

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

示例8: loadImages

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
static List<Image> loadImages(@Nullable Project project) {
  List<Image> ret = ContainerUtil.newArrayListWithCapacity(2);
  Image custom = tryLoadCustom(project);
  if (custom != null) {
    ret.add(custom);
  } else {
    String iconName = getIconName();
    ret.add(ImageLoader.loadFromResource("/ch/retomerz/" + iconName + ".png", ClassicIcon.class));
    ret.add(ImageLoader.loadFromResource("/ch/retomerz/" + iconName + "_128.png", ClassicIcon.class));
  }
  return ret;
}
 
开发者ID:retomerz,项目名称:classic-icon-idea,代码行数:14,代码来源:ClassicIcon.java

示例9: getChildren

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
protected PsiElement[] getChildren(@Nullable PsiElement... children) {
  if (children == null) {
    return PsiElement.EMPTY_ARRAY;
  }

  List<PsiElement> list = ContainerUtil.newArrayListWithCapacity(children.length);
  for (PsiElement child : children) {
    if (child != null) {
      list.add(child);
    }
  }
  return PsiUtilCore.toPsiElementArray(list);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ClsElementImpl.java

示例10: read

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public Collection<TraitFieldDescriptor> read(@NotNull DataInput in) throws IOException {
  int size = readINT(in);
  final Collection<TraitFieldDescriptor> result = ContainerUtil.newArrayListWithCapacity(size);
  while (size-- > 0) {
    result.add(new TraitFieldDescriptor(
      readSINT(in) > 0,
      readSINT(in) > 0,
      readUTF(in),
      readUTF(in)));
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GroovyTraitFieldsFileIndex.java

示例11: getVariants

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
protected List<LookupElement> getVariants(@NotNull final DataNode<ProjectData> projectDataNode, @NotNull final String modulePath) {
  final DataNode<ModuleData> moduleDataNode = findModuleDataNode(projectDataNode, modulePath);
  if (moduleDataNode == null) {
    return Collections.emptyList();
  }

  final Collection<DataNode<TaskData>> tasks = ExternalSystemApiUtil.getChildren(moduleDataNode, ProjectKeys.TASK);
  List<LookupElement> elements = ContainerUtil.newArrayListWithCapacity(tasks.size());
  for (DataNode<TaskData> taskDataNode : tasks) {
    elements.add(LookupElementBuilder.create(taskDataNode.getData().getName()).withIcon(ExternalSystemIcons.Task));
  }
  return elements;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:TaskCompletionProvider.java

示例12: tryGcSoftlyReachableObjects

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
/**
 * Try to force VM to collect soft references if possible.
 * Method doesn't guarantee to succeed, and should not be used in the production code.
 * Commits / hours optimized method code: 5 / 3
 */
@TestOnly
public static void tryGcSoftlyReachableObjects() {
  //long started = System.nanoTime();
  ReferenceQueue<Object> q = new ReferenceQueue<Object>();
  SoftReference<Object> ref = new SoftReference<Object>(new Object(), q);
  ArrayList<SoftReference<?>> list = ContainerUtil.newArrayListWithCapacity(100 + useReference(ref));

  System.gc();
  final long freeMemory = Runtime.getRuntime().freeMemory();

  for (int i = 0; i < 100; i++) {
    if (q.poll() != null) {
      break;
    }

    // full gc is caused by allocation of large enough array below, SoftReference will be cleared after two full gc
    int bytes = Math.min((int)(freeMemory * 0.45), Integer.MAX_VALUE / 2);
    list.add(new SoftReference<byte[]>(new byte[bytes]));
  }

  // use ref is important as to loop to finish with several iterations: long runs of the method (~80 run of PsiModificationTrackerTest)
  // discovered 'ref' being collected and loop iterated 100 times taking a lot of time
  list.ensureCapacity(list.size() + useReference(ref));

  // do not leave a chance for our created SoftReference's content to lie around until next full GC's
  for(SoftReference createdReference:list) createdReference.clear();
  //System.out.println("Done gc'ing refs:" + ((System.nanoTime() - started) / 1000000));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:GCUtil.java

示例13: updateActionsImpl

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void updateActionsImpl(boolean transparentOnly, boolean forced) {
  List<AnAction> newVisibleActions = ContainerUtil.newArrayListWithCapacity(myVisibleActions.size());
  DataContext dataContext = DataManager.getInstance().getDataContext(this);

  Utils.expandActionGroup(myActionGroup, newVisibleActions, myPresentationFactory, dataContext,
                          ActionPlaces.TOOLWINDOW_TITLE, myUpdater.getActionManager(), transparentOnly);

  if (forced || !newVisibleActions.equals(myVisibleActions)) {
    myVisibleActions = newVisibleActions;

    myButtonPanel.removeAll();
    boolean actionAdded = false;
    for (final AnAction action : newVisibleActions) {
      if (action == null) continue;
      final Presentation presentation = myPresentationFactory.getPresentation(action);
      myButtonPanel.add(new ActionButton(action, presentation.getIcon()) {
        @Override
        protected Icon getActiveHoveredIcon() {
          Icon icon = presentation.getHoveredIcon();
          return icon != null ? icon : super.getActiveHoveredIcon();
        }
      });
      myButtonPanel.add(Box.createHorizontalStrut(9));
      actionAdded = true;
    }
    if (actionAdded) {
      myButtonPanel.add(new JLabel(AllIcons.General.Divider));
      myButtonPanel.add(Box.createHorizontalStrut(6));
    }
    addDefaultActions(myButtonPanel);

    revalidate();
    repaint();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:ToolWindowHeader.java

示例14: getConfigurables

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
/**
 * @param tree a map that represents a tree of nodes
 * @param node a current node to process children recursively
 * @return the list of settings for a group or {@code null} for internal node
 */
private static List<Configurable> getConfigurables(Map<String, Node<ConfigurableWrapper>> tree, Node<ConfigurableWrapper> node) {
  if (node.myChildren == null) {
    if (node.myValue == null) {
      return ContainerUtil.newArrayList(); // for group only
    }
    return null;
  }
  List<Configurable> list = ContainerUtil.newArrayListWithCapacity(node.myChildren.size());
  for (Iterator<Object> iterator = node.myChildren.iterator(); iterator.hasNext(); iterator.remove()) {
    Object child = iterator.next();
    if (child instanceof Configurable) {
      list.add((Configurable)child);
    }
    else {
      @SuppressWarnings("unchecked") // expected type
      Node<ConfigurableWrapper> value = (Node<ConfigurableWrapper>)child;
      if (getConfigurables(tree, value) != null) {
        throw new IllegalStateException("unexpected algorithm state");
      }
      list.add(value.myValue);
      tree.remove(value.myValue.getId());
    }
  }
  if (node.myValue == null) {
    return list; // for group only
  }
  for (Configurable configurable : list) {
    node.myValue = node.myValue.addChild(configurable);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ConfigurableExtensionPointUtil.java

示例15: updateActionsImpl

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void updateActionsImpl(boolean transparentOnly, boolean forced) {
  List<AnAction> newVisibleActions = ContainerUtil.newArrayListWithCapacity(myVisibleActions.size());
  DataContext dataContext = getDataContext();

  Utils.expandActionGroup(myActionGroup, newVisibleActions, myPresentationFactory, dataContext,
                          myPlace, myActionManager, transparentOnly);

  if (forced || !newVisibleActions.equals(myVisibleActions)) {
    boolean shouldRebuildUI = newVisibleActions.isEmpty() || myVisibleActions.isEmpty();
    myVisibleActions = newVisibleActions;

    Dimension oldSize = getPreferredSize();

    removeAll();
    mySecondaryActions.removeAll();
    mySecondaryActionsButton = null;
    fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL);

    Dimension newSize = getPreferredSize();

    ((WindowManagerEx)WindowManager.getInstance()).adjustContainerWindow(this, oldSize, newSize);

    if (shouldRebuildUI) {
      revalidate();
    }
    else {
      Container parent = getParent();
      if (parent != null) {
        parent.invalidate();
        parent.validate();
      }
    }

    repaint();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ActionToolbarImpl.java


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