Java 类com.intellij.util.NotNullFunction 实例源码

项目:intellij-ce-playground    文件:BaseConvertToLocalQuickFix.java   
protected PsiElement applyChanges(@NotNull final Project project,
                                  @NotNull final String localName,
                                  @Nullable final PsiExpression initializer,
                                  @NotNull final V variable,
                                  @NotNull final Collection<PsiReference> references,
                                  final boolean delete, @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);

  return ApplicationManager.getApplication().runWriteAction(
    new Computable<PsiElement>() {
      @Override
      public PsiElement compute() {
        final PsiElement newDeclaration = moveDeclaration(elementFactory, localName, variable, initializer, action, references);
        if (delete) {
          beforeDelete(project, variable, newDeclaration);
          variable.normalizeDeclaration();
          variable.delete();
        }
        return newDeclaration;
      }
    }
  );
}
项目:intellij-ce-playground    文件:DataPack.java   
@NotNull
private static PermanentGraph<Integer> buildPermanentGraph(@NotNull List<? extends GraphCommit<Integer>> commits,
                                                           @NotNull RefsModel refsModel,
                                                           @NotNull final VcsLogHashMap hashMap,
                                                           @NotNull Map<VirtualFile, VcsLogProvider> providers) {
  if (commits.isEmpty()) {
    return EmptyPermanentGraph.getInstance();
  }
  NotNullFunction<Integer, Hash> hashGetter = new NotNullFunction<Integer, Hash>() {
    @NotNull
    @Override
    public Hash fun(Integer commitIndex) {
      return hashMap.getHash(commitIndex);
    }
  };
  GraphColorManagerImpl colorManager = new GraphColorManagerImpl(refsModel, hashGetter, getRefManagerMap(providers));
  Set<Integer> branches = getBranchCommitHashIndexes(refsModel.getAllRefs(), hashMap);
  StopWatch sw = StopWatch.start("building graph");
  PermanentGraphImpl<Integer> permanentGraph = PermanentGraphImpl.newInstance(commits, colorManager, branches);
  sw.report();
  return permanentGraph;
}
项目:intellij-ce-playground    文件:FileTypeUsagesCollectorTest.java   
private void doTest(@NotNull Collection<FileType> fileTypes) throws CollectUsagesException {
  final Set<UsageDescriptor> usages = new FileTypeUsagesCollector().getProjectUsages(getProject());
  for (UsageDescriptor usage : usages) {
    assertEquals(1, usage.getValue());
  }
  assertEquals(
    ContainerUtil.map2Set(fileTypes, new NotNullFunction<FileType, String>() {
      @NotNull
      @Override
      public String fun(FileType fileType) {
        return fileType.getName();
      }
    }),
    ContainerUtil.map2Set(usages, new NotNullFunction<UsageDescriptor, String>() {
      @NotNull
      @Override
      public String fun(UsageDescriptor usageDescriptor) {
        return usageDescriptor.getKey();
      }
    })
  );
}
项目:intellij-ce-playground    文件:CachesHolder.java   
public void iterateAllCaches(final NotNullFunction<ChangesCacheFile, Boolean> consumer) {
  final AbstractVcs[] vcses = myPlManager.getAllActiveVcss();
  for (AbstractVcs vcs : vcses) {
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    if (provider instanceof CachingCommittedChangesProvider) {
      final Map<VirtualFile, RepositoryLocation> map = getAllRootsUnderVcs(vcs);
      for (VirtualFile root : map.keySet()) {
        final RepositoryLocation location = map.get(root);
        final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location);
        if (Boolean.TRUE.equals(consumer.fun(cacheFile))) {
          return;
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:CommittedChangesCache.java   
private boolean hasCachesWithEmptiness(final boolean emptiness) {
  final Ref<Boolean> resultRef = new Ref<Boolean>(Boolean.FALSE);
  myCachesHolder.iterateAllCaches(new NotNullFunction<ChangesCacheFile, Boolean>() {
    @Override
    @NotNull
    public Boolean fun(final ChangesCacheFile changesCacheFile) {
      try {
        if (changesCacheFile.isEmpty() == emptiness) {
          resultRef.set(true);
          return true;
        }
      }
      catch (IOException e) {
        LOG.info(e);
      }
      return false;
    }
  });
  return resultRef.get();
}
项目:intellij-ce-playground    文件:ChangesViewContentManager.java   
private void updateExtensionTabs() {
  final ChangesViewContentEP[] contentEPs = myProject.getExtensions(ChangesViewContentEP.EP_NAME);
  for(ChangesViewContentEP ep: contentEPs) {
    final NotNullFunction<Project,Boolean> predicate = ep.newPredicateInstance(myProject);
    if (predicate == null) continue;
    Content epContent = findEPContent(ep);
    final Boolean predicateResult = predicate.fun(myProject);
    if (predicateResult.equals(Boolean.TRUE) && epContent == null) {
      addExtensionTab(ep);
    }
    else if (predicateResult.equals(Boolean.FALSE) && epContent != null) {
      if (!(epContent.getComponent() instanceof ContentStub)) {
        ep.getInstance(myProject).disposeContent();
      }
      myContentManager.removeContent(epContent, true);
    }
  }
}
项目:intellij-ce-playground    文件:PyExecuteSelectionAction.java   
private static Collection<RunContentDescriptor> getConsoles(Project project) {
  PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project);

  if (toolWindow != null && toolWindow.getToolWindow().isVisible()) {
    RunContentDescriptor selectedContentDescriptor = toolWindow.getSelectedContentDescriptor();
    return selectedContentDescriptor != null ? Lists.newArrayList(selectedContentDescriptor) : Lists.<RunContentDescriptor>newArrayList();
  }

  Collection<RunContentDescriptor> descriptors =
    ExecutionHelper.findRunningConsole(project, new NotNullFunction<RunContentDescriptor, Boolean>() {
      @NotNull
      @Override
      public Boolean fun(RunContentDescriptor dom) {
        return dom.getExecutionConsole() instanceof PyCodeExecutor && isAlive(dom);
      }
    });

  if (descriptors.isEmpty() && toolWindow != null) {
    return toolWindow.getConsoleContentDescriptors();
  }
  else {
    return descriptors;
  }
}
项目:intellij-ce-playground    文件:NavigationGutterIconBuilder.java   
private static <T> NotNullLazyValue<List<SmartPsiElementPointer>> createPointersThunk(boolean lazy,
                                                                                      final Project project,
                                                                                      final Factory<Collection<T>> targets,
                                                                                      final NotNullFunction<T, Collection<? extends PsiElement>> converter) {
  if (!lazy) {
    return NotNullLazyValue.createConstantValue(calcPsiTargets(project, targets.create(), converter));
  }

  return new NotNullLazyValue<List<SmartPsiElementPointer>>() {
    @Override
    @NotNull
    public List<SmartPsiElementPointer> compute() {
      return calcPsiTargets(project, targets.create(), converter);
    }
  };
}
项目:intellij-ce-playground    文件:DomFileDescription.java   
/**
 * Consider using {@link DomService#getXmlFileHeader(com.intellij.psi.xml.XmlFile)} when implementing this.
 */
@SuppressWarnings({"MethodMayBeStatic"})
@NotNull
public List<String> getAllowedNamespaces(@NotNull String namespaceKey, @NotNull XmlFile file) {
  final NotNullFunction<XmlTag, List<String>> function = myNamespacePolicies.get(namespaceKey);
  if (function instanceof ConstantFunction) {
    return function.fun(null);
  }

  if (function != null) {
    final XmlDocument document = file.getDocument();
    if (document != null) {
      final XmlTag tag = document.getRootTag();
      if (tag != null) {
        return function.fun(tag);
      }
    }
  } else {
    return Collections.singletonList(namespaceKey);
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:AndroidDslContributor.java   
private void logClassPathOnce(@NotNull Project project) {
  List<VirtualFile> files = GradleBuildClasspathManager.getInstance(project).getAllClasspathEntries();
  if (ContainerUtil.equalsIdentity(files, myLastClassPath)) {
    return;
  }
  myLastClassPath = files;

  List<String> paths = ContainerUtil.map(files, new NotNullFunction<VirtualFile, String>() {
    @NotNull
    @Override
    public String fun(VirtualFile vf) {
      return vf.getPath();
    }
  });
  String classPath = Joiner.on(':').join(paths);
  LOG.info(String.format("Android DSL resolver classpath (project %1$s): %2$s", project.getName(), classPath));
}
项目:intellij-ce-playground    文件:RepositoryBrowserComponent.java   
public void setRepositoryURLs(SVNURL[] urls,
                              final boolean showFiles,
                              @Nullable NotNullFunction<RepositoryBrowserComponent, Expander> defaultExpanderFactory,
                              boolean expandFirst) {
  RepositoryTreeModel model = new RepositoryTreeModel(myVCS, showFiles, this);

  if (defaultExpanderFactory != null) {
    model.setDefaultExpanderFactory(defaultExpanderFactory);
  }

  model.setRoots(urls);
  Disposer.register(this, model);
  myRepositoryTree.setModel(model);

  if (expandFirst) {
    myRepositoryTree.expandRow(0);
  }
}
项目:intellij-ce-playground    文件:SvnChangeList.java   
public SvnRepositoryContentRevision createRevisionLazily(final String path, final boolean isBeforeRevision) {
  final boolean knownAsDirectory = myKnownAsDirectories.contains(path);
  final FilePath localPath = getLocalPath(path, new NotNullFunction<File, Boolean>() {
    @NotNull
    public Boolean fun(final File file) {
      if (knownAsDirectory) return Boolean.TRUE;
      // list will be next
      myWithoutDirStatus.add(new Pair<Integer, Boolean>(myList.size(), isBeforeRevision));
      return Boolean.FALSE;
    }
  });
  long revision = getRevision(isBeforeRevision);
  return localPath == null
         ? SvnRepositoryContentRevision.createForRemotePath(myVcs, myRepositoryRoot, path, knownAsDirectory, revision)
         : SvnRepositoryContentRevision.create(myVcs, myRepositoryRoot, path, localPath, revision);
}
项目:intellij-ce-playground    文件:SvnMergeInfoRootPanelManual.java   
public SvnMergeInfoRootPanelManual(@NotNull Project project,
                                   @NotNull NotNullFunction<WCInfoWithBranches, WCInfoWithBranches> refresher,
                                   @NotNull Runnable listener,
                                   boolean onlyOneRoot,
                                   @NotNull WCInfoWithBranches info) {
  myOnlyOneRoot = onlyOneRoot;
  myInfo = info;
  myProject = project;
  myRefresher = refresher;
  myListener = listener;
  myBranchToLocal = ContainerUtil.newHashMap();

  init();
  myInclude.setVisible(!onlyOneRoot);
  initWithData();
}
项目:tools-idea    文件:BaseConvertToLocalQuickFix.java   
protected PsiElement applyChanges(@NotNull final Project project,
                                  @NotNull final String localName,
                                  @Nullable final PsiExpression initializer,
                                  @NotNull final V variable,
                                  @NotNull final Collection<PsiReference> references,
                                  final boolean delete, @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);

  return ApplicationManager.getApplication().runWriteAction(
    new Computable<PsiElement>() {
      @Override
      public PsiElement compute() {
        final PsiElement newDeclaration = moveDeclaration(elementFactory, localName, variable, initializer, action, references);
        if (delete) {
          beforeDelete(project, variable, newDeclaration);
          variable.normalizeDeclaration();
          variable.delete();
        }
        return newDeclaration;
      }
    }
  );
}
项目:tools-idea    文件:FileTypeUsagesCollectorTest.java   
private void doTest(@NotNull Collection<FileType> fileTypes) throws CollectUsagesException {
  final Set<UsageDescriptor> usages = new FileTypeUsagesCollector().getProjectUsages(getProject());
  for (UsageDescriptor usage : usages) {
    assertEquals(1, usage.getValue());
  }
  assertEquals(
    ContainerUtil.map2Set(fileTypes, new NotNullFunction<FileType, String>() {
      @NotNull
      @Override
      public String fun(FileType fileType) {
        return fileType.getName();
      }
    }),
    ContainerUtil.map2Set(usages, new NotNullFunction<UsageDescriptor, String>() {
      @NotNull
      @Override
      public String fun(UsageDescriptor usageDescriptor) {
        return usageDescriptor.getKey();
      }
    })
  );
}
项目:tools-idea    文件:CachesHolder.java   
public void iterateAllCaches(final NotNullFunction<ChangesCacheFile, Boolean> consumer) {
  final AbstractVcs[] vcses = myPlManager.getAllActiveVcss();
  for (AbstractVcs vcs : vcses) {
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    if (provider instanceof CachingCommittedChangesProvider) {
      final Map<VirtualFile, RepositoryLocation> map = getAllRootsUnderVcs(vcs);
      for (VirtualFile root : map.keySet()) {
        final RepositoryLocation location = map.get(root);
        final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location);
        if (Boolean.TRUE.equals(consumer.fun(cacheFile))) {
          return;
        }
      }
    }
  }
}
项目:tools-idea    文件:CommittedChangesCache.java   
private boolean hasCachesWithEmptiness(final boolean emptiness) {
  final Ref<Boolean> resultRef = new Ref<Boolean>(Boolean.FALSE);
  myCachesHolder.iterateAllCaches(new NotNullFunction<ChangesCacheFile, Boolean>() {
    @Override
    @NotNull
    public Boolean fun(final ChangesCacheFile changesCacheFile) {
      try {
        if (changesCacheFile.isEmpty() == emptiness) {
          resultRef.set(true);
          return true;
        }
      }
      catch (IOException e) {
        LOG.info(e);
      }
      return false;
    }
  });
  return resultRef.get();
}
项目:tools-idea    文件:ChangesViewContentManager.java   
private void updateExtensionTabs() {
  final ChangesViewContentEP[] contentEPs = myProject.getExtensions(ChangesViewContentEP.EP_NAME);
  for(ChangesViewContentEP ep: contentEPs) {
    final NotNullFunction<Project,Boolean> predicate = ep.newPredicateInstance(myProject);
    if (predicate == null) continue;
    Content epContent = findEPContent(ep);
    final Boolean predicateResult = predicate.fun(myProject);
    if (predicateResult.equals(Boolean.TRUE) && epContent == null) {
      addExtensionTab(ep);
    }
    else if (predicateResult.equals(Boolean.FALSE) && epContent != null) {
      if (!(epContent.getComponent() instanceof ContentStub)) {
        ep.getInstance(myProject).disposeContent();
      }
      myContentManager.removeContent(epContent, true);
    }
  }
}
项目:tools-idea    文件:ExecutionHelper.java   
/** @deprecated use lookup by user data (to remove in IDEA 13) */
public static Collection<RunContentDescriptor> findRunningConsoleByCmdLine(final Project project,
                                                                           @NotNull final NotNullFunction<String, Boolean> cmdLineMatcher) {
  return findRunningConsole(project, new NotNullFunction<RunContentDescriptor, Boolean>() {
    @NotNull
    @Override
    public Boolean fun(RunContentDescriptor selectedContent) {
      final ProcessHandler processHandler = selectedContent.getProcessHandler();
      if (processHandler instanceof OSProcessHandler && !processHandler.isProcessTerminated()) {
        final String commandLine = ((OSProcessHandler)processHandler).getCommandLine();
        return cmdLineMatcher.fun(commandLine);
      }
      return false;
    }
  });
}
项目:tools-idea    文件:ExecutionHelper.java   
public static Collection<RunContentDescriptor> findRunningConsole(final Project project,
                                                                  @NotNull final NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) {
  final ExecutionManager executionManager = ExecutionManager.getInstance(project);

  final RunContentDescriptor selectedContent = executionManager.getContentManager().getSelectedContent();
  if (selectedContent != null) {
    final ToolWindow toolWindow = ExecutionManager.getInstance(project).getContentManager().getToolWindowByDescriptor(selectedContent);
    if (toolWindow != null && toolWindow.isVisible()) {
      if (descriptorMatcher.fun(selectedContent)) {
        return Collections.singletonList(selectedContent);
      }
    }
  }

  final ArrayList<RunContentDescriptor> result = ContainerUtil.newArrayList();
  for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
    if (descriptorMatcher.fun(runContentDescriptor)) {
      result.add(runContentDescriptor);
    }
  }
  return result;
}
项目:tools-idea    文件:DomFileDescription.java   
/**
 * Consider using {@link DomService#getXmlFileHeader(com.intellij.psi.xml.XmlFile)} when implementing this.
 */
@SuppressWarnings({"MethodMayBeStatic"})
@NotNull
public List<String> getAllowedNamespaces(@NotNull String namespaceKey, @NotNull XmlFile file) {
  final NotNullFunction<XmlTag, List<String>> function = myNamespacePolicies.get(namespaceKey);
  if (function instanceof ConstantFunction) {
    return function.fun(null);
  }

  if (function != null) {
    final XmlDocument document = file.getDocument();
    if (document != null) {
      final XmlTag tag = document.getRootTag();
      if (tag != null) {
        return function.fun(tag);
      }
    }
  } else {
    return Collections.singletonList(namespaceKey);
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:FogBugzRepository.java   
private Task[] getCases(String q) throws Exception {
  HttpClient client = login(getLoginMethod());
  PostMethod method = new PostMethod(getUrl() + "/api.asp");
  method.addParameter("token", token);
  method.addParameter("cmd", "search");
  method.addParameter("q", q);
  method.addParameter("cols", "sTitle,fOpen,dtOpened,dtLastUpdated,ixCategory");
  int status = client.executeMethod(method);
  if (status != 200) {
    throw new Exception("Error listing cases: " + method.getStatusLine());
  }
  Document document = new SAXBuilder(false).build(method.getResponseBodyAsStream()).getDocument();
  XPath path = XPath.newInstance("/response/cases/case");
  final XPath commentPath = XPath.newInstance("events/event");
  @SuppressWarnings("unchecked") final List<Element> nodes = (List<Element>)path.selectNodes(document);
  final List<Task> tasks = ContainerUtil.mapNotNull(nodes, new NotNullFunction<Element, Task>() {
    @NotNull
    @Override
    public Task fun(Element element) {
      return createCase(element, commentPath);
    }
  });
  return tasks.toArray(new Task[tasks.size()]);
}
项目:tools-idea    文件:SvnChangeList.java   
public SvnRepositoryContentRevision createRevisionLazily(final String path, final boolean isBeforeRevision) {
  final boolean knownAsDirectory = myKnownAsDirectories.contains(path);
  final FilePath localPath = getLocalPath(path, new NotNullFunction<File, Boolean>() {
    @NotNull
    public Boolean fun(final File file) {
      if (knownAsDirectory) return Boolean.TRUE;
      // list will be next
      myWithoutDirStatus.add(new Pair<Integer, Boolean>(myList.size(), isBeforeRevision));
      return Boolean.FALSE;
    }
  });
  final SvnRepositoryContentRevision contentRevision =
    SvnRepositoryContentRevision.create(myVcs, myRepositoryRoot, path, localPath, getRevision(isBeforeRevision));
  if (knownAsDirectory) {
    ((FilePathImpl) contentRevision.getFile()).setIsDirectory(true);
  }
  return contentRevision;
}
项目:targetprocess-intellij-plugin    文件:TargetProcessMethodFactory.java   
private HttpMethod build() {
    GetMethod method = new GetMethod(url);
    method.setPath(path.toString());

    method.addRequestHeader("Accept", "application/json");

    NameValuePair[] params =
        ContainerUtil.map2Array(parameters.entrySet(), NameValuePair.class, new NotNullFunction<Map.Entry<String, String>, NameValuePair>() {
            @NotNull
            @Override
            public NameValuePair fun(Map.Entry<String, String> entry) {
                return new NameValuePair(entry.getKey(), entry.getValue());
            }
        });
    method.setQueryString(params);

    return method;
}
项目:consulo-tasks    文件:FogBugzRepository.java   
private Task[] getCases(String q) throws Exception {
  HttpClient client = login(getLoginMethod());
  PostMethod method = new PostMethod(getUrl() + "/api.asp");
  method.addParameter("token", token);
  method.addParameter("cmd", "search");
  method.addParameter("q", q);
  method.addParameter("cols", "sTitle,fOpen,dtOpened,dtLastUpdated,ixCategory");
  int status = client.executeMethod(method);
  if (status != 200) {
    throw new Exception("Error listing cases: " + method.getStatusLine());
  }
  Document document = new SAXBuilder(false).build(method.getResponseBodyAsStream()).getDocument();
  XPath path = XPath.newInstance("/response/cases/case");
  final XPath commentPath = XPath.newInstance("events/event");
  @SuppressWarnings("unchecked") final List<Element> nodes = (List<Element>)path.selectNodes(document);
  final List<Task> tasks = ContainerUtil.mapNotNull(nodes, new NotNullFunction<Element, Task>() {
    @NotNull
    @Override
    public Task fun(Element element) {
      return createCase(element, commentPath);
    }
  });
  return tasks.toArray(new Task[tasks.size()]);
}
项目:consulo-dotnet    文件:DotNetTypeRefCacheUtil.java   
@Exported
@NotNull
@RequiredReadAction
private static <E extends PsiElement> DotNetTypeRef getResultCacheResultImpl(@NotNull Key<CachedValue<DotNetTypeRef>> cachedValueKey,
        @NotNull E element,
        @NotNull Key dropKey,
        @NotNull final NotNullFunction<E, DotNetTypeRef> resolver)
{
    Class<? extends NotNullFunction> aClass = resolver.getClass();
    if(!BitUtil.isSet(aClass.getModifiers(), Modifier.STATIC))
    {
        throw new IllegalArgumentException("Accepted only static resolver");
    }

    CachedValue<DotNetTypeRef> cachedValue = element.getUserData(cachedValueKey);
    if(cachedValue == null)
    {
        DotNetTypeRefCachedValueProvider<E> provider = new DotNetTypeRefCachedValueProvider<>(dropKey, element, resolver);

        cachedValue = ((UserDataHolderEx) element).putUserDataIfAbsent(cachedValueKey, CachedValuesManager.getManager(element.getProject()).createCachedValue(provider, false));

        return cachedValue.getValue();
    }
    return cachedValue.getValue();
}
项目:consulo-dotnet    文件:CompositeDotNetNamespaceAsElement.java   
@RequiredReadAction
@NotNull
@Override
public Collection<PsiElement> findChildren(@NotNull String name,
        @NotNull GlobalSearchScope globalSearchScope,
        @NotNull NotNullFunction<PsiElement, PsiElement> transformer,
        @NotNull ChildrenFilter filter)
{
    Collection<Collection<PsiElement>> list = new SmartList<>();
    for(DotNetNamespaceAsElement dotNetNamespaceAsElement : myList)
    {
        Collection<PsiElement> children = dotNetNamespaceAsElement.findChildren(name, globalSearchScope, transformer, filter);
        list.add(children);
    }
    return list.isEmpty() ? Collections.emptyList() : ContainerUtil.concat(list);
}
项目:consulo-dotnet    文件:BaseDotNetNamespaceAsElement.java   
@SuppressWarnings("unchecked")
@NotNull
public static List<PsiElement> transformData(@NotNull Iterable<? extends PsiElement> collection, int size, NotNullFunction<PsiElement, PsiElement> transformer)
{
    if(size == 0)
    {
        return Collections.emptyList();
    }

    List<PsiElement> list = new ArrayList<>(size);
    for(PsiElement element : collection)
    {
        list.add(transformer.fun(element));
    }
    return list;
}
项目:consulo-dotnet    文件:DotNetPsiSearcher.java   
@NotNull
@RequiredReadAction
public DotNetTypeDeclaration[] findTypes(@NotNull String vmQName, @NotNull GlobalSearchScope scope, @NotNull NotNullFunction<DotNetTypeDeclaration, DotNetTypeDeclaration> transformer)
{
    Collection<? extends DotNetTypeDeclaration> declarations = findTypesImpl(vmQName, scope);
    if(declarations.isEmpty())
    {
        return DotNetTypeDeclaration.EMPTY_ARRAY;
    }
    List<DotNetTypeDeclaration> list = new ArrayList<DotNetTypeDeclaration>(declarations.size());

    for(DotNetTypeDeclaration declaration : declarations)
    {
        list.add(transformer.fun(declaration));
    }

    return ContainerUtil.toArray(list, DotNetTypeDeclaration.ARRAY_FACTORY);
}
项目:consulo    文件:FileTypeUsagesCollectorTest.java   
private void doTest(@Nonnull Collection<FileType> fileTypes) throws CollectUsagesException {
  final Set<UsageDescriptor> usages = new FileTypeUsagesCollector().getProjectUsages(getProject());
  for (UsageDescriptor usage : usages) {
    assertEquals(1, usage.getValue());
  }
  assertEquals(
    ContainerUtil.map2Set(fileTypes, new NotNullFunction<FileType, String>() {
      @Nonnull
      @Override
      public String fun(FileType fileType) {
        return fileType.getName();
      }
    }),
    ContainerUtil.map2Set(usages, new NotNullFunction<UsageDescriptor, String>() {
      @Nonnull
      @Override
      public String fun(UsageDescriptor usageDescriptor) {
        return usageDescriptor.getKey();
      }
    })
  );
}
项目:consulo    文件:PrintElementManagerImpl.java   
@SuppressWarnings("unchecked")
PrintElementManagerImpl(@Nonnull final LinearGraph linearGraph,
                        @Nonnull final PermanentGraphInfo myPermanentGraph,
                        @Nonnull GraphColorManager colorManager) {
  myLinearGraph = linearGraph;
  myColorGetter = new ColorGetterByLayoutIndex(linearGraph, myPermanentGraph, colorManager);
  myGraphElementComparator = new GraphElementComparatorByLayoutIndex(new NotNullFunction<Integer, Integer>() {
    @Nonnull
    @Override
    public Integer fun(Integer nodeIndex) {
      int nodeId = linearGraph.getNodeId(nodeIndex);
      if (nodeId < 0) return nodeId;
      return myPermanentGraph.getPermanentGraphLayout().getLayoutIndex(nodeId);
    }
  });
}
项目:consulo    文件:CachesHolder.java   
public void iterateAllCaches(final NotNullFunction<ChangesCacheFile, Boolean> consumer) {
  final AbstractVcs[] vcses = myPlManager.getAllActiveVcss();
  for (AbstractVcs vcs : vcses) {
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    if (provider instanceof CachingCommittedChangesProvider) {
      final Map<VirtualFile, RepositoryLocation> map = getAllRootsUnderVcs(vcs);
      for (VirtualFile root : map.keySet()) {
        final RepositoryLocation location = map.get(root);
        final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location);
        if (Boolean.TRUE.equals(consumer.fun(cacheFile))) {
          return;
        }
      }
    }
  }
}
项目:consulo    文件:CommittedChangesCache.java   
private boolean hasCachesWithEmptiness(final boolean emptiness) {
  final Ref<Boolean> resultRef = new Ref<Boolean>(Boolean.FALSE);
  myCachesHolder.iterateAllCaches(new NotNullFunction<ChangesCacheFile, Boolean>() {
    @Override
    @Nonnull
    public Boolean fun(final ChangesCacheFile changesCacheFile) {
      try {
        if (changesCacheFile.isEmpty() == emptiness) {
          resultRef.set(true);
          return true;
        }
      }
      catch (IOException e) {
        LOG.info(e);
      }
      return false;
    }
  });
  return resultRef.get();
}
项目:consulo    文件:RunIdeConsoleAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  List<String> languages = IdeScriptEngineManager.getInstance().getLanguages();
  if (languages.size() == 1) {
    runConsole(e, languages.iterator().next());
    return;
  }

  DefaultActionGroup actions =
          new DefaultActionGroup(ContainerUtil.map(languages, (NotNullFunction<String, AnAction>)language -> new DumbAwareAction(language) {
            @Override
            public void actionPerformed(@Nonnull AnActionEvent e1) {
              runConsole(e1, language);
            }
          }));
  JBPopupFactory.getInstance().createActionGroupPopup("Script Engine", actions, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, false).
          showInBestPositionFor(e.getDataContext());
}
项目:consulo    文件:ExecutionHelper.java   
public static Collection<RunContentDescriptor> findRunningConsole(final Project project,
                                                                  @Nonnull final NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) {
  final ExecutionManager executionManager = ExecutionManager.getInstance(project);

  final RunContentDescriptor selectedContent = executionManager.getContentManager().getSelectedContent();
  if (selectedContent != null) {
    final ToolWindow toolWindow = ExecutionManager.getInstance(project).getContentManager().getToolWindowByDescriptor(selectedContent);
    if (toolWindow != null && toolWindow.isVisible()) {
      if (descriptorMatcher.fun(selectedContent)) {
        return Collections.singletonList(selectedContent);
      }
    }
  }

  final ArrayList<RunContentDescriptor> result = ContainerUtil.newArrayList();
  for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
    if (descriptorMatcher.fun(runContentDescriptor)) {
      result.add(runContentDescriptor);
    }
  }
  return result;
}
项目:consulo-javascript    文件:DescriptionByAnotherPsiElementRegistrar.java   
@Override
public void initComponent()
{
    for(final DescriptionByAnotherPsiElementProvider<?> provider : DescriptionByAnotherPsiElementProvider.EP_NAME.getExtensions())
    {
        EditorNotificationProviders.registerProvider(new NotNullFunction<Project, EditorNotificationProvider<?>>()
        {
            @NotNull
            @Override
            public EditorNotificationProvider<?> fun(Project project)
            {
                //noinspection unchecked
                return new DescriptionByAnotherPsiElementEditorNotification(project, provider);
            }
        });
    }
}
项目:consulo-java    文件:BaseConvertToLocalQuickFix.java   
protected PsiElement applyChanges(final @NotNull Project project,
                                  final @NotNull String localName,
                                  final @Nullable PsiExpression initializer,
                                  final @NotNull V variable,
                                  final @NotNull Collection<PsiReference> references,
                                  final @NotNull NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);

  return ApplicationManager.getApplication().runWriteAction(
    new Computable<PsiElement>() {
      @Override
      public PsiElement compute() {
        final PsiElement newDeclaration = moveDeclaration(elementFactory, localName, variable, initializer, action, references);
        beforeDelete(project, variable, newDeclaration);
        variable.normalizeDeclaration();
        variable.delete();
        return newDeclaration;
      }
    }
  );
}
项目:consulo-java    文件:JavaParameters.java   
@Nullable
private static NotNullFunction<OrderEntry, VirtualFile[]> computeRootProvider(int classPathType, final Sdk jdk)
{
    return (classPathType & JDK_ONLY) == 0 ? null : orderEntry ->
    {
        if(orderEntry instanceof ModuleExtensionWithSdkOrderEntry)
        {
            final Sdk sdk = ((ModuleExtensionWithSdkOrderEntry) orderEntry).getSdk();
            if(sdk == null)
            {
                return VirtualFile.EMPTY_ARRAY;
            }
            if(sdk.getSdkType() == jdk)
            {
                return jdk.getRootProvider().getFiles(BinariesOrderRootType.getInstance());
            }
            return orderEntry.getFiles(BinariesOrderRootType.getInstance());
        }
        return orderEntry.getFiles(BinariesOrderRootType.getInstance());
    };
}
项目:consulo-java    文件:JavaParameters.java   
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType, Sdk jdk)
{
    if((classPathType & JDK_ONLY) == 0)
    {
        enumerator = enumerator.withoutSdk();
    }
    if((classPathType & TESTS_ONLY) == 0)
    {
        enumerator = enumerator.productionOnly();
    }
    OrderRootsEnumerator rootsEnumerator = enumerator.classes();
    final NotNullFunction<OrderEntry, VirtualFile[]> provider = computeRootProvider(classPathType, jdk);
    if(provider != null)
    {
        rootsEnumerator = rootsEnumerator.usingCustomRootProvider(provider);
    }
    return rootsEnumerator;
}
项目:intellij-ce-playground    文件:BuildingTargetProgressMessage.java   
private static String composeMessageText(Collection<? extends BuildTarget<?>> targets, Event event) {
  String targetsString = StringUtil.join(targets, new NotNullFunction<BuildTarget<?>, String>() {
    @NotNull
    @Override
    public String fun(BuildTarget<?> dom) {
      return dom.getPresentableName();
    }
  }, ", ");
  return (event == Event.STARTED ? "Started" : "Finished") + " building " + targetsString;
}