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

The following examples show how to use com.intellij.util.containers.ContainerUtil#newArrayList() . 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: ArrangementRuleAliasDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public ArrangementRuleAliasDialog(@Nullable Project project,
                                  @Nonnull ArrangementStandardSettingsManager settingsManager,
                                  @Nonnull ArrangementColorsProvider colorsProvider,
                                  @Nonnull Collection<StdArrangementRuleAliasToken> tokens,
                                  @Nonnull Set<String> tokensInUse) {
  super(project, false);

  final List<StdArrangementRuleAliasToken> tokenList = ContainerUtil.newArrayList(tokens);
  myEditor = new ArrangementRuleAliasesListEditor(settingsManager, colorsProvider, tokenList, tokensInUse);
  if (!tokenList.isEmpty()) {
    myEditor.selectItem(tokenList.get(0));
  }

  setTitle(ApplicationBundle.message("arrangement.settings.section.rule.custom.token.title"));
  init();
}
 
Example 2
Source File: CopyReferenceAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean doCopy(List<PsiElement> elements, @Nullable final Project project, @Nullable Editor editor) {
  if (elements.isEmpty()) return false;

  List<String> fqns = ContainerUtil.newArrayList();
  for (PsiElement element : elements) {
    String fqn = elementToFqn(element, editor);
    if (fqn == null) return false;

    fqns.add(fqn);
  }

  String toCopy = StringUtil.join(fqns, "\n");

  CopyPasteManager.getInstance().setContents(new MyTransferable(toCopy));

  setStatusBarText(project, IdeBundle.message("message.reference.to.fqn.has.been.copied", toCopy));
  return true;
}
 
Example 3
Source File: XWatchesViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void updateSessionData() {
  List<XExpression> watchExpressions = ContainerUtil.newArrayList();
  List<? extends WatchNode> children = myRootNode.getWatchChildren();
  for (WatchNode child : children) {
    watchExpressions.add(child.getExpression());
  }
  XDebugSession session = getSession(getTree());
  XExpression[] expressions = watchExpressions.toArray(new XExpression[watchExpressions.size()]);
  if (session != null) {
    ((XDebugSessionImpl)session).setWatchExpressions(expressions);
  }
  else {
    XDebugSessionData data = getData(XDebugSessionData.DATA_KEY, getTree());
    if (data != null) {
      data.setWatchExpressions(expressions);
    }
  }
}
 
Example 4
Source File: DesktopSaveAndSyncHandlerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void refreshOpenFiles() {
  List<VirtualFile> files = ContainerUtil.newArrayList();

  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    for (VirtualFile file : FileEditorManager.getInstance(project).getSelectedFiles()) {
      if (file instanceof NewVirtualFile) {
        files.add(file);
      }
    }
  }

  if (!files.isEmpty()) {
    // refresh open files synchronously so it doesn't wait for potentially longish refresh request in the queue to finish
    RefreshQueue.getInstance().refresh(false, false, null, files);
  }
}
 
Example 5
Source File: ApiStructureViewElement.java    From ApiDebugger with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
    PsiElement element = getElement();
    if (element instanceof ApiPsiFile) {
        ApiDebugger type = PsiTreeUtil.findChildOfType(element, ApiDebugger.class);
        if (type != null) {

            return ContainerUtil.newArrayList();
        }
    }
    return ContainerUtil.emptyList();
}
 
Example 6
Source File: FormatChangedTextUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<PsiFile> getChangedFilesFromDirs(@Nonnull Project project, @Nonnull List<PsiDirectory> dirs) {
  ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  Collection<Change> changes = ContainerUtil.newArrayList();

  for (PsiDirectory dir : dirs) {
    changes.addAll(changeListManager.getChangesIn(dir.getVirtualFile()));
  }

  return getChangedFiles(project, changes);
}
 
Example 7
Source File: ArrangementSectionRule.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static ArrangementSectionRule create(@javax.annotation.Nullable String start, @Nullable String end, @Nonnull List<StdArrangementMatchRule> rules) {
  final List<StdArrangementMatchRule> matchRules = ContainerUtil.newArrayList();
  if (StringUtil.isNotEmpty(start)) {
    matchRules.add(createSectionRule(start, START_SECTION));
  }
  matchRules.addAll(rules);
  if (StringUtil.isNotEmpty(end)) {
    matchRules.add(createSectionRule(end, END_SECTION));
  }
  return new ArrangementSectionRule(start, end, matchRules);
}
 
Example 8
Source File: ExcludedFilesList.java    From consulo with Apache License 2.0 5 votes vote down vote up
private List<NamedScopesHolder> getScopeHolders() {
  List<NamedScopesHolder> holders = ContainerUtil.newArrayList();
  Project project = getScopeHolderProject();
  holders.add(DependencyValidationManager.getInstance(project));
  holders.add(NamedScopeManager.getInstance(project));
  return holders;
}
 
Example 9
Source File: ExecutionHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static List<RunContentDescriptor> collectConsolesByDisplayName(final Project project, @Nonnull NotNullFunction<String, Boolean> titleMatcher) {
  List<RunContentDescriptor> result = ContainerUtil.newArrayList();
  final ExecutionManager executionManager = ExecutionManager.getInstance(project);
  for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
    if (titleMatcher.fun(runContentDescriptor.getDisplayName())) {
      result.add(runContentDescriptor);
    }
  }
  return result;
}
 
Example 10
Source File: ApplyPatchDifferentiatedDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void run() {
  final FilePresentationModel filePresentationModel = myRecentPathFileChange.get();
  final VirtualFile file = filePresentationModel != null ? filePresentationModel.getVf() : null;
  if (file == null) {
    ApplicationManager.getApplication().invokeLater(myReset, ModalityState.stateForComponent(myCenterPanel));
    return;
  }

  final PatchReader patchReader = loadPatches(file);
  List<FilePatch> filePatches = patchReader != null ? ContainerUtil.newArrayList(patchReader.getPatches()) : Collections.emptyList();
  if (!ContainerUtil.isEmpty(myBinaryShelvedPatches)) {
    filePatches.addAll(myBinaryShelvedPatches);
  }
  final List<AbstractFilePatchInProgress> matchedPatches = new MatchPatchPaths(myProject).execute(filePatches, myUseProjectRootAsPredefinedBase);

  ApplicationManager.getApplication().invokeLater(() -> {
    if (myShouldUpdateChangeListName) {
      myChangeListChooser.setSuggestedName(file.getNameWithoutExtension().replace('_', ' ').trim());
    }
    myPatches.clear();
    myPatches.addAll(matchedPatches);
    myReader = patchReader;
    updateTree(true);
    paintBusy(false);
    updateOkActions();
  }, ModalityState.stateForComponent(myCenterPanel));
}
 
Example 11
Source File: LabelPainter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static Pair<List<Pair<String, LabelIcon>>, Integer> calculatePresentation(@Nonnull List<RefGroup> refGroups,
                                                                                  @Nonnull FontMetrics fontMetrics,
                                                                                  int height,
                                                                                  @Nonnull Color background,
                                                                                  int availableWidth,
                                                                                  boolean compact) {
  int width = LEFT_PADDING + RIGHT_PADDING;

  List<Pair<String, LabelIcon>> labels = ContainerUtil.newArrayList();
  if (refGroups.isEmpty()) return Pair.create(labels, width);

  if (compact) return calculateCompactPresentation(refGroups, fontMetrics, height, background, availableWidth);
  return calculateLongPresentation(refGroups, fontMetrics, height, background, availableWidth);
}
 
Example 12
Source File: VcsLogUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<? extends VcsFullCommitDetails> getDetails(@Nonnull VcsLogProvider logProvider, @Nonnull VirtualFile root, @Nonnull List<String> hashes)
        throws VcsException {
  List<VcsFullCommitDetails> result = ContainerUtil.newArrayList();
  logProvider.readFullDetails(root, hashes, result::add);
  return result;
}
 
Example 13
Source File: CoverageOptionsConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private List<JComponent> collectExtensionOptionsComponents() {
  List<JComponent> additionalPanels = ContainerUtil.newArrayList();
  for (CoverageOptions coverageOptions : getExtensions()) {
    additionalPanels.add(coverageOptions.getComponent());
  }
  return additionalPanels;
}
 
Example 14
Source File: ArrangementUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<StdArrangementMatchRule> collectMatchRules(@Nonnull List<ArrangementSectionRule> sections) {
  final List<StdArrangementMatchRule> matchRules = ContainerUtil.newArrayList();
  for (ArrangementSectionRule section : sections) {
    matchRules.addAll(section.getMatchRules());
  }
  return matchRules;
}
 
Example 15
Source File: Goal.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
public List<String> parse(PsiFile psiFile, ConfigurationContext configurationContext) {
	String cmd = getCommandLine();
	cmd = ApplicationSettings.get().applyAliases(cmd, psiFile, configurationContext);

	return ContainerUtil.newArrayList(StringUtil.tokenize(new StringTokenizer(cmd)));
}
 
Example 16
Source File: DirectoryAccessChecker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static List<String> split(String line) {
  return ContainerUtil.newArrayList(StringUtil.tokenize(line, " \t"));
}
 
Example 17
Source File: ExternalModuleBuildClasspathPojo.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public ExternalModuleBuildClasspathPojo() {
  // Used by IJ serialization
  this("___DUMMY___", ContainerUtil.<String>newArrayList());
}
 
Example 18
Source File: CollectionListModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SafeVarargs
public CollectionListModel(@Nonnull T... items) {
  myItems = ContainerUtil.newArrayList(items);
}
 
Example 19
Source File: TabContentLayout.java    From consulo with Apache License 2.0 4 votes vote down vote up
void setTabDoubleClickActions(@Nonnull AnAction... actions) {
  myDoubleClickActions = ContainerUtil.newArrayList(actions);
}
 
Example 20
Source File: NotificationData.java    From consulo with Apache License 2.0 4 votes vote down vote up
public List<String> getRegisteredListenerIds() {
  return ContainerUtil.newArrayList(myListenerMap.keySet());
}