Java 类com.intellij.openapi.util.Condition 实例源码

项目:intellij-postfix-templates    文件:CustomJavaStringPostfixTemplate.java   
public static Condition<PsiElement> withProjectClassCondition(@Nullable String conditionClass, Condition<PsiElement> psiElementCondition) {
    if (conditionClass == null) {
        return psiElementCondition;
    } else {
        final Condition<PsiElement> finalPsiElementCondition = psiElementCondition;

        return psiElement -> {
            if (finalPsiElementCondition.value(psiElement)) {
                final Project project = psiElement.getProject();
                PsiFile psiFile = psiElement.getContainingFile().getOriginalFile();
                VirtualFile virtualFile = psiFile.getVirtualFile();
                Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
                assert module != null;
                return JavaPsiFacade.getInstance(project).findClass(conditionClass, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true)) != null;
            } else {
                return false;
            }
        };
    }
}
项目:intellij-ce-playground    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() {
    @Override
    public boolean value(Pair<AnAction, KeyStroke> pair) {
      final AnAction action = pair.getFirst();
      final Presentation presentation = action.getTemplatePresentation().clone();
      AnActionEvent event = new AnActionEvent(null, ctx,
                                              ActionPlaces.UNKNOWN,
                                              presentation,
                                              ActionManager.getInstance(),
                                              0);

      ActionUtil.performDumbAwareUpdate(action, event, true);
      return presentation.isEnabled() && presentation.isVisible();
    }
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目:jetbrains-hacklang    文件:HackUtil.java   
public static List<HackVarname> findLocalVarnames(HackVarname var)
{
    List<HackVarname> result = new ArrayList<HackVarname>();

    Condition<PsiElement> parentCheck = psiElement
            -> psiElement instanceof HackFunctionDefinition || psiElement instanceof HackClassMemberDeclaration;
    PsiElement parentFunction = PsiTreeUtil.findFirstParent(var, false, parentCheck);
    Collection<HackVarname> siblingVars = PsiTreeUtil.findChildrenOfType(parentFunction, HackVarname.class);

    for (HackVarname sibling : siblingVars) {
        if (var.getText().equals(sibling.getText())) {
            result.add(sibling);
        }
    }

    return result;
}
项目:intellij-ce-playground    文件:SvnCheckinEnvironment.java   
private void reportCommittedRevisions(Set<String> feedback, String committedRevisions) {
  final Project project = mySvnVcs.getProject();
  final String message = SvnBundle.message("status.text.comitted.revision", committedRevisions);
  if (feedback == null) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
                                                      public void run() {
                                                        new VcsBalloonProblemNotifier(project, message, MessageType.INFO).run();
                                                      }
                                                    }, new Condition<Object>() {
      @Override
      public boolean value(Object o) {
        return (! project.isOpen()) || project.isDisposed();
      }
    });
  } else {
    feedback.add("Subversion: " + message);
  }
}
项目:intellij-ce-playground    文件:XDebuggerTreeCreator.java   
@NotNull
@Override
public Tree createTree(@NotNull Pair<XValue, String> descriptor) {
  final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(), descriptor.getFirst());
  tree.setRoot(root, true);
  tree.setSelectionRow(0);
  // expand root on load
  tree.expandNodesOnLoad(new Condition<TreeNode>() {
    @Override
    public boolean value(TreeNode node) {
      return node == root;
    }
  });
  return tree;
}
项目:intellij-ce-playground    文件:LanguageConsoleBuilder.java   
/**
 * todo This API doesn't look good, but it is much better than force client to know low-level details
 */
public static AnAction registerExecuteAction(@NotNull LanguageConsoleView console,
                                             @NotNull final Consumer<String> executeActionHandler,
                                             @NotNull String historyType,
                                             @Nullable String historyPersistenceId,
                                             @Nullable Condition<LanguageConsoleView> enabledCondition) {
  ConsoleExecuteAction.ConsoleExecuteActionHandler handler = new ConsoleExecuteAction.ConsoleExecuteActionHandler(true) {
    @Override
    void doExecute(@NotNull String text, @NotNull LanguageConsoleView consoleView) {
      executeActionHandler.consume(text);
    }
  };

  ConsoleExecuteAction action = new ConsoleExecuteAction(console, handler, enabledCondition);
  action.registerCustomShortcutSet(action.getShortcutSet(), console.getConsoleEditor().getComponent());
  new ConsoleHistoryController(historyType, historyPersistenceId, console).install();
  return action;
}
项目:intellij-ce-playground    文件:NonBundledPluginsUsagesCollector.java   
@NotNull
public Set<UsageDescriptor> getUsages() {
  final IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
  final List<IdeaPluginDescriptor> nonBundledEnabledPlugins = ContainerUtil.filter(plugins, new Condition<IdeaPluginDescriptor>() {
    public boolean value(final IdeaPluginDescriptor d) {
      return d.isEnabled() && !d.isBundled() && d.getPluginId() != null;
    }
  });

  return ContainerUtil.map2Set(nonBundledEnabledPlugins, new Function<IdeaPluginDescriptor, UsageDescriptor>() {
    @Override
    public UsageDescriptor fun(IdeaPluginDescriptor descriptor) {
      return new UsageDescriptor(descriptor.getPluginId().getIdString(), 1);
    }
  });
}
项目:intellij-ce-playground    文件:DeviceChooserDialog.java   
public DeviceChooserDialog(@NotNull AndroidFacet facet,
                           @NotNull IAndroidTarget projectTarget,
                           boolean multipleSelection,
                           @Nullable String[] selectedSerials,
                           @Nullable Condition<IDevice> filter) {
  super(facet.getModule().getProject(), true);
  setTitle(AndroidBundle.message("choose.device.dialog.title"));

  getOKAction().setEnabled(false);

  myDeviceChooser = new DeviceChooser(multipleSelection, getOKAction(), facet, projectTarget, filter);
  Disposer.register(myDisposable, myDeviceChooser);
  myDeviceChooser.addListener(new DeviceChooserListener() {
    @Override
    public void selectedDevicesChanged() {
      updateOkButton();
    }
  });

  init();
  myDeviceChooser.init(selectedSerials);
}
项目:intellij-ce-playground    文件:ProjectSdksModel.java   
public void createAddActions(DefaultActionGroup group,
                             final JComponent parent,
                             final Consumer<Sdk> updateTree,
                             @Nullable Condition<SdkTypeId> filter) {
  final SdkType[] types = SdkType.getAllTypes();
  for (final SdkType type : types) {
    if (filter != null && !filter.value(type)) continue;
    final AnAction addAction = new DumbAwareAction(type.getPresentableName(), null, type.getIconForAddAction()) {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        doAdd(parent, type, updateTree);
      }
    };
    group.add(addAction);
  }
}
项目:intellij-ce-playground    文件:DirDiffTableModel.java   
private void reportException(final String htmlContent) {
  Runnable balloonShower = new Runnable() {
    @Override
    public void run() {
      Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).
        setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).
        createBalloon();
      final Rectangle rect = myPanel.getPanel().getBounds();
      final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
      final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
      balloon.show(point, Balloon.Position.below);
      Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
    }
  };
  ApplicationManager.getApplication().invokeLater(balloonShower, new Condition() {
    @Override
    public boolean value(Object o) {
      return !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed());
    }
  }
  );
}
项目:intellij-ce-playground    文件:HgBranchPopup.java   
/**
 * @param currentRepository Current repository, which means the repository of the currently open or selected file.
 */
public static HgBranchPopup getInstance(@NotNull Project project, @NotNull HgRepository currentRepository) {

  HgRepositoryManager manager = HgUtil.getRepositoryManager(project);
  HgProjectSettings hgProjectSettings = ServiceManager.getService(project, HgProjectSettings.class);
  HgMultiRootBranchConfig hgMultiRootBranchConfig = new HgMultiRootBranchConfig(manager.getRepositories());

  Condition<AnAction> preselectActionCondition = new Condition<AnAction>() {
    @Override
    public boolean value(AnAction action) {
      return false;
    }
  };
  return new HgBranchPopup(currentRepository, manager, hgMultiRootBranchConfig, hgProjectSettings,
                           preselectActionCondition);
}
项目:intellij-ce-playground    文件:CustomResourceBundleState.java   
@Nullable
public CustomResourceBundleState removeNonExistentFiles(final VirtualFileManager virtualFileManager) {
  final List<String> existentFiles = ContainerUtil.filter(myFileUrls, new Condition<String>() {
    @Override
    public boolean value(String url) {
      return virtualFileManager.findFileByUrl(url) != null;
    }
  });
  if (existentFiles.isEmpty()) {
    return null;
  }
  final CustomResourceBundleState customResourceBundleState = new CustomResourceBundleState();
  customResourceBundleState.myFileUrls.addAll(existentFiles);
  customResourceBundleState.myBaseName = myBaseName;
  return customResourceBundleState;
}
项目:intellij-ce-playground    文件:IgnoredPropertiesFilesSuffixesManager.java   
public List<PropertiesFile> getPropertiesFilesWithoutTranslation(final ResourceBundle resourceBundle, final Set<String> keys) {
  final PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile();
  return ContainerUtil.filter(resourceBundle.getPropertiesFiles(), new Condition<PropertiesFile>() {
    @Override
    public boolean value(PropertiesFile propertiesFile) {
      if (defaultPropertiesFile.equals(propertiesFile)) {
        return false;
      }
      for (String key : keys) {
        if (propertiesFile.findPropertyByKey(key) == null && !myState.getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile))) {
          return true;
        }
      }
      return false;
    }
  });
}
项目:intellij-ce-playground    文件:PredefinedSearchScopeProviderImpl.java   
@Nullable
private static SearchScope getSelectedFilesScope(final Project project, @Nullable DataContext dataContext) {
  final VirtualFile[] filesOrDirs = dataContext == null ? null : CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
  if (filesOrDirs != null) {
    final List<VirtualFile> selectedFiles = ContainerUtil.filter(filesOrDirs, new Condition<VirtualFile>() {
      @Override
      public boolean value(VirtualFile file) {
        return !file.isDirectory();
      }
    });
    if (!selectedFiles.isEmpty()) {
      return new DelegatingGlobalSearchScope(GlobalSearchScope.filesScope(project, selectedFiles)) {
        @NotNull
        @Override
        public String getDisplayName() {
          return "Selected Files";
        }
      };
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PathsList.java   
private Iterator<String> chooseFirstTimeItems(String path) {
  if (path == null) {
    return emptyIterator();
  }
  final StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator);
  // in JDK 1.5 StringTokenizer implements Enumeration<Object> rather then Enumeration<String>, need to convert
  final Enumeration<String> en = new Enumeration<String>() {
    @Override
    public boolean hasMoreElements() {
      return tokenizer.hasMoreElements();
    }

    @Override
    public String nextElement() {
      return (String)tokenizer.nextElement();
    }
  };
  return FilteringIterator.create(iterate(en), new Condition<String>() {
    @Override
    public boolean value(String element) {
      element = element.trim();
      return !element.isEmpty() && !myPathSet.contains(element);
    }
  });
}
项目:intellij-ce-playground    文件:GitRefManagerTest.java   
private void setUpTracking(@NotNull Collection<VcsRef> refs) {
  cd(myProjectRoot);
  for (final VcsRef ref : refs) {
    if (ref.getType() == GitRefManager.LOCAL_BRANCH) {
      final String localBranch = ref.getName();
      if (ContainerUtil.exists(refs, new Condition<VcsRef>() {
        @Override
        public boolean value(VcsRef remoteRef) {
          return remoteRef.getType() == GitRefManager.REMOTE_BRANCH && remoteRef.getName().replace("origin/", "").equals(localBranch);
        }
      })) {
        git("config branch." + localBranch + ".remote origin");
        git("config branch." + localBranch + ".merge refs/heads/" + localBranch);
      }
    }
  }
}
项目:intellij-ce-playground    文件:SvnCheckinEnvironment.java   
@NotNull
private List<FilePath> getCommitables(@NotNull List<Change> changes) {
  ChangesUtil.CaseSensitiveFilePathList list = ChangesUtil.getPathsList(changes);

  for (FilePath path : ContainerUtil.newArrayList(list.getResult())) {
    list.addParents(path, new Condition<FilePath>() {
      @Override
      public boolean value(@NotNull FilePath file) {
        Status status = getStatus(file);

        return status != null && status.is(StatusType.STATUS_ADDED, StatusType.STATUS_REPLACED);
      }
    });
  }

  return list.getResult();
}
项目:intellij-ce-playground    文件:ComboControl.java   
static JComboBox initComboBox(final JComboBox comboBox, final Condition<String> validity) {
  comboBox.setEditable(false);
  comboBox.setPrototypeDisplayValue(new ComboBoxItem("A", null));
  comboBox.setRenderer(new DefaultListCellRenderer() {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      final Pair<String, Icon> pair = (Pair<String, Icon>)value;
      final String text = pair == null ? null : pair.first;
      setText(text);
      final Dimension dimension = getPreferredSize();
      if (!validity.value(text)) {
        setFont(getFont().deriveFont(Font.ITALIC));
        setForeground(JBColor.RED);
      }
      setIcon(pair == null ? null : pair.second);
      setPreferredSize(new Dimension(-1, dimension.height));
      return this;
    }
  });
  return comboBox;
}
项目:intellij-ce-playground    文件:BackpointerUtil.java   
public static boolean isBackpointerReference(PsiExpression expression, Condition<PsiField> value) {
  if (expression instanceof PsiParenthesizedExpression) {
    final PsiExpression contents = ((PsiParenthesizedExpression)expression).getExpression();
    return isBackpointerReference(contents, value);
  }
  if (!(expression instanceof PsiReferenceExpression)) {
    return false;
  }
  final PsiReferenceExpression reference = (PsiReferenceExpression)expression;
  final PsiElement qualifier = reference.getQualifier();
  if (qualifier != null && !(qualifier instanceof PsiThisExpression)) {
    return false;
  }
  final PsiElement referent = reference.resolve();
  return referent instanceof PsiField && value.value((PsiField)referent);
}
项目:intellij-ce-playground    文件:ScratchFileActions.java   
@Override
public void update(AnActionEvent e) {
  Project project = e.getProject();
  JBIterable<VirtualFile> files = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY));
  if (project == null || files.isEmpty()) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  Condition<VirtualFile> isScratch = fileFilter(project);
  if (!files.filter(not(isScratch)).isEmpty()) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }
  Set<Language> langs = files.filter(isScratch).transform(fileLanguage(project)).filter(notNull()).
    addAllTo(ContainerUtil.<Language>newLinkedHashSet());
  String langName = langs.size() == 1 ? langs.iterator().next().getDisplayName() : langs.size() + " different";
  e.getPresentation().setText(String.format("Change %s (%s)...", getLanguageTerm(), langName));
  e.getPresentation().setEnabledAndVisible(true);
}
项目:intellij-ce-playground    文件:ProxyCallback.java   
@Override
public void updateParameters(@NotNull Command command) {
  // TODO: This is quite messy logic for determining group for host - either ProxyCallback could be unified with ProxyModule
  // TODO: or group name resolved in ProxyModule could be saved in Command instance.
  // TODO: This will be done later after corresponding refactorings.
  String proxyHostParameter = ContainerUtil.find(command.getParameters(), new Condition<String>() {
    @Override
    public boolean value(String s) {
      return s.contains("http-proxy-port");
    }
  });

  if (!StringUtil.isEmpty(proxyHostParameter) && myUrl != null && myProxyAuthentication != null) {
    String group = getHostGroup(proxyHostParameter);

    command.put("--config-option");
    command.put(String.format("servers:%s:http-proxy-username=%s", group, myProxyAuthentication.getUserName()));
    command.put("--config-option");
    command.put(String.format("servers:%s:http-proxy-password=%s", group, String.valueOf(myProxyAuthentication.getPassword())));
  }
}
项目:AppleScript-IDEA    文件:AppleScriptResolveUtil.java   
@NotNull
public static ResolveResult[] toCandidateInfoArray(@Nullable List<? extends PsiElement> elements) {
  if (elements == null) {
    return ResolveResult.EMPTY_ARRAY;
  }
  elements = ContainerUtil.filter(elements, (Condition<PsiElement>) Objects::nonNull);
  final ResolveResult[] result = new ResolveResult[elements.size()];
  for (int i = 0, size = elements.size(); i < size; i++) {
    result[i] = new PsiElementResolveResult(elements.get(i));
  }
  return result;
}
项目:intellij-postfix-templates    文件:CustomJavaScriptStringPostfixTemplate.java   
@NotNull
public static Condition<PsiElement> getCondition(String clazz) {
    Condition<PsiElement> psiElementCondition = type2psiCondition.get(clazz);

    if (psiElementCondition != null) {
        return psiElementCondition;
    } else {
        return MyJavaPostfixTemplatesUtils.isCustomClass(clazz);
    }
}
项目:GravSupport    文件:GravFileTemplateUtil.java   
public static List<FileTemplate> getAvailableThemeConfigurationTemplates() {
    return getApplicableTemplates(new Condition<FileTemplate>() {
        @Override
        public boolean value(FileTemplate fileTemplate) {
            return GravConfigurationFileType.DEFAULT_EXTENSION.equals(fileTemplate.getExtension());
        }
    });
}
项目:intellij-ce-playground    文件:UIPropertyBinding.java   
public void updateRemoveButton(JButton button, Condition<T> removable) {
  final JTable table = getComponent();
  final ListSelectionModel selectionModel = table.getSelectionModel();
  boolean enable = false;
  if (!selectionModel.isSelectionEmpty()) {
    enable = true;
    for (int i : table.getSelectedRows()) {
      if (!removable.value(myModel.getItems().get(i))) {
        enable = false;
        break;
      }
    }
  }
  button.setEnabled(enable);
}
项目:intellij-ce-playground    文件:ZipEntryMap.java   
@Override
public final Iterator<Entry<String, ArchiveHandler.EntryInfo>> iterator() {
  return ContainerUtil.mapIterator(ContainerUtil.iterate(entries, Condition.NOT_NULL).iterator(),
                                   new Function<ArchiveHandler.EntryInfo, Entry<String, ArchiveHandler.EntryInfo>>() {
                                     @Override
                                     public Entry<String, ArchiveHandler.EntryInfo> fun(ArchiveHandler.EntryInfo entry) {
                                       return new SimpleEntry<String, ArchiveHandler.EntryInfo>(getRelativePath(entry), entry);
                                     }
                                   });
}
项目:intellij-ce-playground    文件:TemplateDataLanguageMappings.java   
public static List<Language> getTemplateableLanguages() {
  return ContainerUtil.findAll(Language.getRegisteredLanguages(), new Condition<Language>() {
    @Override
    public boolean value(final Language language) {
      if (language == Language.ANY) return false;
      if (language instanceof TemplateLanguage || language instanceof DependentLanguage || language instanceof InjectableLanguage) return false;
      if (language.getBaseLanguage() != null) return value(language.getBaseLanguage());
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:ComboBoxAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  JComponent button = (JComponent)e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY);
  if (button == null) {
    Component contextComponent = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
    JRootPane rootPane = UIUtil.getParentOfType(JRootPane.class, contextComponent);
    if (rootPane != null) {
      button = (ComboBoxButton)
        UIUtil.uiTraverser().withRoot(rootPane).bfsTraversal().filter(new Condition<Component>() {
          @Override
          public boolean value(Component component) {
            return component instanceof ComboBoxButton && ((ComboBoxButton)component).getMyAction() == ComboBoxAction.this;
          }
        }).first();
    }
    if (button == null) return;
  }
  if (!button.isShowing()) return;
  if (button instanceof ComboBoxButton) {
    ((ComboBoxButton)button).showPopup();
  } else {
    DataContext context = e.getDataContext();
    Project project = e.getProject();
    if (project == null) return;
    DefaultActionGroup group = createPopupActionGroup(button);
    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
      myPopupTitle, group, context, false, shouldShowDisabledActions(), false, null, getMaxRows(), getPreselectCondition());
    popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
    popup.showCenteredInCurrentWindow(project);
  }
}
项目:intellij-ce-playground    文件:ProjectJdkTable.java   
@Nullable
public Sdk findMostRecentSdk(Condition<Sdk> condition) {
  Sdk found = null;
  for (Sdk each : getAllJdks()) {
    if (!condition.value(each)) continue;
    if (found == null) {
      found = each;
      continue;
    }
    if (Comparing.compare(each.getVersionString(), found.getVersionString()) > 0) found = each;
  }
  return found;
}
项目:intellij-ce-playground    文件:GitConfig.java   
@Nullable
public static GitRemoteBranch findRemoteBranch(@NotNull String remoteBranchName, @NotNull final String remoteName,
                                               @NotNull final Collection<GitRemoteBranch> remoteBranches) {
  final String branchName = GitBranchUtil.stripRefsPrefix(remoteBranchName);
  return ContainerUtil.find(remoteBranches, new Condition<GitRemoteBranch>() {
    @Override
    public boolean value(GitRemoteBranch branch) {
      return branch.getNameForRemoteOperations().equals(branchName) && branch.getRemote().getName().equals(remoteName);
    }
  });
}
项目:intellij-ce-playground    文件:HgRepositoryImpl.java   
@NotNull
@Override
public List<String> getUnappliedPatchNames() {
  final List<String> appliedPatches = HgUtil.getNamesWithoutHashes(getMQAppliedPatches());
  return ContainerUtil.filter(getAllPatchNames(), new Condition<String>() {
    @Override
    public boolean value(String s) {
      return !appliedPatches.contains(s);
    }
  });
}
项目:intellij-ce-playground    文件:JavaPsiFacadeImpl.java   
@NotNull
public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
  PsiElementFinder[] finders = filteredFinders();
  Condition<PsiClass> classesFilter = getFilterFromFinders(scope, finders);

  List<PsiClass> result = null;
  for (PsiElementFinder finder : finders) {
    PsiClass[] classes = finder.getClasses(psiPackage, scope);
    if (classes.length == 0) continue;
    if (result == null) result = new ArrayList<PsiClass>(classes.length);
    filterClassesAndAppend(finder, classesFilter, classes, result);
  }

  return result == null ? PsiClass.EMPTY_ARRAY : result.toArray(new PsiClass[result.size()]);
}
项目:intellij-ce-playground    文件:JavaPsiFacadeImpl.java   
private static void filterClassesAndAppend(PsiElementFinder finder,
                                           @Nullable Condition<PsiClass> classesFilter,
                                           @NotNull PsiClass[] classes,
                                           @NotNull List<PsiClass> result) {
  for (PsiClass psiClass : classes) {
    if (psiClass == null) {
      LOG.error("Finder " + finder + " returned null PsiClass");
      continue;
    }
    if (classesFilter == null || classesFilter.value(psiClass)) {
      result.add(psiClass);
    }
  }
}
项目:intellij-ce-playground    文件:VcsDirectoryConfigurationPanel.java   
@NotNull
private List<MapInfo> getSelectedRegisteredRoots() {
  Collection<MapInfo> selection = myDirectoryMappingTable.getSelection();
  return ContainerUtil.filter(selection, new Condition<MapInfo>() {
    @Override
    public boolean value(MapInfo info) {
      return info.type == MapInfo.Type.NORMAL || info.type == MapInfo.Type.INVALID;
    }
  });
}
项目:intellij-ce-playground    文件:VisiblePackBuilder.java   
private boolean matchesAllFilters(@NotNull final VcsCommitMetadata commit,
                                  @NotNull final PermanentGraph<Integer> permanentGraph,
                                  @NotNull List<VcsLogDetailsFilter> detailsFilters,
                                  @Nullable final Set<Integer> matchingHeads) {
  boolean matchesAllDetails = ContainerUtil.and(detailsFilters, new Condition<VcsLogDetailsFilter>() {
    @Override
    public boolean value(VcsLogDetailsFilter filter) {
      return filter.matches(commit);
    }
  });
  return matchesAllDetails && matchesAnyHead(permanentGraph, commit, matchingHeads);
}
项目:intellij-ce-playground    文件:ModuleDataService.java   
@NotNull
@Override
public Computable<Collection<Module>> computeOrphanData(@NotNull final Collection<DataNode<ModuleData>> toImport,
                                                        @NotNull final ProjectData projectData,
                                                        @NotNull final Project project,
                                                        @NotNull final IdeModifiableModelsProvider modelsProvider) {
  return new Computable<Collection<Module>>() {
    @Override
    public Collection<Module> compute() {
      List<Module> orphanIdeModules = ContainerUtil.newSmartList();

      for (Module module : modelsProvider.getModules()) {
        if (!ExternalSystemApiUtil.isExternalSystemAwareModule(projectData.getOwner(), module)) continue;
        final String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
        if (projectData.getLinkedExternalProjectPath().equals(rootProjectPath)) {
          final String projectPath = ExternalSystemApiUtil.getExternalProjectPath(module);
          final String projectId = ExternalSystemApiUtil.getExternalProjectId(module);

          final DataNode<ModuleData> found = ContainerUtil.find(toImport, new Condition<DataNode<ModuleData>>() {
            @Override
            public boolean value(DataNode<ModuleData> node) {
              final ModuleData moduleData = node.getData();
              return moduleData.getId().equals(projectId) && moduleData.getLinkedExternalProjectPath().equals(projectPath);
            }
          });

          if (found == null) {
            orphanIdeModules.add(module);
          }
        }
      }

      return orphanIdeModules;
    }
  };
}
项目:intellij-ce-playground    文件:PushController.java   
private static boolean allNodesAreLoaded(@NotNull Collection<RepositoryNode> nodes) {
  return !ContainerUtil.exists(nodes, new Condition<RepositoryNode>() {
    @Override
    public boolean value(@NotNull RepositoryNode node) {
      return node.isLoading();
    }
  });
}
项目:intellij-ce-playground    文件:FileReferenceHelperRegistrar.java   
/**
 * @deprecated this method is broken, please avoid using it, use getHelpers() instead
 */
@Deprecated
public static <T extends PsiFileSystemItem> FileReferenceHelper getHelper(@NotNull final T psiFileSystemItem) {
  final VirtualFile file = psiFileSystemItem.getVirtualFile();
  if (file == null) return null;
  final Project project = psiFileSystemItem.getProject();
  return ContainerUtil.find(getHelpers(), new Condition<FileReferenceHelper>() {
    @Override
    public boolean value(final FileReferenceHelper fileReferenceHelper) {
      return fileReferenceHelper.isMine(project, file);
    }
  });
}
项目:intellij-ce-playground    文件:ClassInheritorsSearch.java   
public SearchParameters(@NotNull final PsiClass aClass, @NotNull SearchScope scope, final boolean checkDeep, final boolean checkInheritance,
                        boolean includeAnonymous, @NotNull final Condition<String> nameCondition) {
  myClass = aClass;
  myScope = scope;
  myCheckDeep = checkDeep;
  myCheckInheritance = checkInheritance;
  myIncludeAnonymous = includeAnonymous;
  myNameCondition = nameCondition;
}
项目:intellij-ce-playground    文件:VcsDirectoryConfigurationPanel.java   
@NotNull
private Collection<VcsRootError> findUnregisteredRoots() {
  return ContainerUtil.filter(VcsRootErrorsFinder.getInstance(myProject).find(), new Condition<VcsRootError>() {
    @Override
    public boolean value(VcsRootError error) {
      return error.getType() == VcsRootError.Type.UNREGISTERED_ROOT;
    }
  });
}