Java Code Examples for com.intellij.util.containers.ContainerUtil#map2Set()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#map2Set() .
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: FileWatcherTest.java From consulo with Apache License 2.0 | 6 votes |
private void assertEvent(Class<? extends VFileEvent> type, String... paths) { List<VFileEvent> events = getEvents(type.getSimpleName(), null); assertEquals(events.toString(), paths.length, events.size()); Set<String> pathSet = ContainerUtil.map2Set(paths, new Function<String, String>() { @Override public String fun(final String path) { return FileUtil.toSystemIndependentName(path); } }); for (VFileEvent event : events) { assertTrue(event.toString(), type.isInstance(event)); VirtualFile eventFile = event.getFile(); assertNotNull(event.toString(), eventFile); assertTrue(eventFile + " not in " + Arrays.toString(paths), pathSet.remove(eventFile.getPath())); } }
Example 2
Source File: IoTestUtil.java From consulo with Apache License 2.0 | 6 votes |
private static char getFirstFreeDriveLetter() { final Set<Character> roots = ContainerUtil.map2Set(File.listRoots(), new Function<File, Character>() { @Override public Character fun(File root) { return root.getPath().toUpperCase(Locale.US).charAt(0); } }); char drive = 0; for (char c = 'E'; c <= 'Z'; c++) { if (!roots.contains(c)) { drive = c; break; } } assertFalse("Occupied: " + roots.toString(), drive == 0); return drive; }
Example 3
Source File: FakeVisiblePackBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private VisiblePack build(@Nonnull DataPackBase oldPack, @Nonnull VisibleGraphImpl<Integer> oldGraph, @Nonnull VcsLogFilterCollection filters) { final PermanentGraphInfo<Integer> info = oldGraph.buildSimpleGraphInfo(); Set<Integer> heads = ContainerUtil.map2Set(info.getPermanentGraphLayout().getHeadNodeIndex(), integer -> info.getPermanentCommitsInfo().getCommitId(integer)); RefsModel newRefsModel = createRefsModel(oldPack.getRefsModel(), heads, oldGraph, oldPack.getLogProviders()); DataPackBase newPack = new DataPackBase(oldPack.getLogProviders(), newRefsModel, false); GraphColorManagerImpl colorManager = new GraphColorManagerImpl(newRefsModel, DataPack.createHashGetter(myHashMap), DataPack.getRefManagerMap(oldPack.getLogProviders())); VisibleGraph<Integer> newGraph = new VisibleGraphImpl<>(new CollapsedController(new BaseController(info), info, null), info, colorManager); return new VisiblePack(newPack, newGraph, true, filters); }
Example 4
Source File: AbstractRunConfigurationTypeUsagesCollector.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public final Set<UsageDescriptor> getProjectUsages(@Nonnull final Project project) { final Set<String> runConfigurationTypes = new HashSet<String>(); UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { if (project.isDisposed()) return; final RunManager runManager = RunManager.getInstance(project); for (RunConfiguration runConfiguration : runManager.getAllConfigurationsList()) { if (runConfiguration != null && isApplicable(runManager, runConfiguration)) { final ConfigurationFactory configurationFactory = runConfiguration.getFactory(); final ConfigurationType configurationType = configurationFactory.getType(); final StringBuilder keyBuilder = new StringBuilder(); keyBuilder.append(configurationType.getId()); if (configurationType.getConfigurationFactories().length > 1) { keyBuilder.append(".").append(configurationFactory.getName()); } runConfigurationTypes.add(keyBuilder.toString()); } } } }); return ContainerUtil.map2Set(runConfigurationTypes, runConfigurationType -> new UsageDescriptor(runConfigurationType, 1)); }
Example 5
Source File: PushController.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private <R extends Repository, S extends PushSource, T extends PushTarget> List<PushSupport<R, S, T>> getAffectedSupports() { Collection<Repository> repositories = myGlobalRepositoryManager.getRepositories(); Collection<AbstractVcs> vcss = ContainerUtil.map2Set(repositories, new Function<Repository, AbstractVcs>() { @Override public AbstractVcs fun(@Nonnull Repository repository) { return repository.getVcs(); } }); return ContainerUtil.map(vcss, new Function<AbstractVcs, PushSupport<R, S, T>>() { @Override public PushSupport<R, S, T> fun(AbstractVcs vcs) { //noinspection unchecked return DvcsUtil.getPushSupport(vcs); } }); }
Example 6
Source File: HaskellPsiUtil.java From intellij-haskforce with Apache License 2.0 | 5 votes |
@NotNull public static Set<String> getImportModuleNames(@NotNull List<Import> imports) { return ContainerUtil.map2Set(imports, new Function<Import, String>() { @Override public String fun(Import anImport) { return anImport.module; } }); }
Example 7
Source File: AllFileTemplatesConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Inject public AllFileTemplatesConfigurable(Project project) { myProject = project; myManager = getInstance(project); myScheme = myManager.getCurrentScheme(); myInternalTemplateNames = ContainerUtil.map2Set(myManager.getInternalTemplates(), template -> template.getName()); }
Example 8
Source File: MultipleRootsInjectedFileViewProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public Set<Language> getLanguages() { FileViewProvider original = myOriginalProvider; Set<Language> languages = original.getLanguages(); Language base = original.getBaseLanguage(); return ContainerUtil.map2Set(languages, (language) -> language == base ? myLanguage : language); }
Example 9
Source File: PermanentCommitsInfoImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Set<CommitId> convertToCommitIdSet(@Nonnull Collection<Integer> commitIndexes) { return ContainerUtil.map2Set(commitIndexes, new Function<Integer, CommitId>() { @Override public CommitId fun(Integer integer) { return getCommitId(integer); } }); }
Example 10
Source File: CollapsedActionManager.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull Set<Integer> convertToDelegateNodeIndex(@Nonnull Collection<Integer> compiledNodeIndexes) { return ContainerUtil.map2Set(compiledNodeIndexes, new Function<Integer, Integer>() { @Override public Integer fun(Integer nodeIndex) { return convertToDelegateNodeIndex(nodeIndex); } }); }
Example 11
Source File: LinearGraphUtils.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Set<Integer> convertNodeIndexesToIds(@Nonnull final LinearGraph graph, @Nonnull Collection<Integer> nodeIndexes) { return ContainerUtil.map2Set(nodeIndexes, new Function<Integer, Integer>() { @Override public Integer fun(Integer nodeIndex) { return graph.getNodeId(nodeIndex); } }); }
Example 12
Source File: PluginsUsagesCollector.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public Set<UsageDescriptor> getUsages(@Nullable Project project) { final List<PluginDescriptor> plugins = PluginManager.getPlugins(); final List<PluginDescriptor> enabledPlugins = ContainerUtil.filter(plugins, d -> d.isEnabled() && !PluginIds.isPlatformPlugin(d.getPluginId())); return ContainerUtil.map2Set(enabledPlugins, descriptor -> new UsageDescriptor(descriptor.getPluginId().getIdString(), 1)); }
Example 13
Source File: AbstractApplicationUsagesCollector.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Set<UsageDescriptor> getApplicationUsages(@Nonnull final ApplicationStatisticsPersistence persistence) { final Map<String, Integer> result = new HashMap<String, Integer>(); for (Set<UsageDescriptor> usageDescriptors : persistence.getApplicationData(getGroupId()).values()) { for (UsageDescriptor usageDescriptor : usageDescriptors) { final String key = usageDescriptor.getKey(); final Integer count = result.get(key); result.put(key, count == null ? 1 : count.intValue() + 1); } } return ContainerUtil.map2Set(result.entrySet(), entry -> new UsageDescriptor(entry.getKey(), entry.getValue())); }
Example 14
Source File: VisiblePackBuilder.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private Set<Integer> getMatchedCommitIndex(@Nullable Collection<CommitId> commits) { if (commits == null) { return null; } return ContainerUtil.map2Set(commits, commitId -> myHashMap.getCommitIndex(commitId.getHash(), commitId.getRoot())); }
Example 15
Source File: DisabledPluginsUsagesCollector.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Set<UsageDescriptor> getUsages(@Nullable Project project) { return ContainerUtil.map2Set(PluginManager.getDisabledPlugins(), descriptor -> new UsageDescriptor(descriptor, 1)); }
Example 16
Source File: VcsUsagesCollector.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Set<UsageDescriptor> getProjectUsages(@Nonnull Project project) { return ContainerUtil.map2Set(ProjectLevelVcsManager.getInstance(project).getAllActiveVcss(), vcs -> new UsageDescriptor(vcs.getName(), 1)); }
Example 17
Source File: UsageTrigger.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Set<UsageDescriptor> getUsages(@Nullable final Project project) { final State state = UsageTrigger.getInstance().getState(); return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); }
Example 18
Source File: PsiElement2UsageTargetComposite.java From consulo with Apache License 2.0 | 4 votes |
@Override public VirtualFile[] getFiles() { Set<VirtualFile> files = ContainerUtil.map2Set(myDescriptor.getAllElements(), element -> PsiUtilCore.getVirtualFile(element)); return VfsUtilCore.toVirtualFileArray(files); }
Example 19
Source File: PantsPythonSetupDataService.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
@Override public void importData( @NotNull final Collection<DataNode<PythonSetupData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull final IdeModifiableModelsProvider modelsProvider ) { final Set<PythonInterpreterInfo> interpreters = ContainerUtil.map2Set( toImport, node -> node.getData().getInterpreterInfo() ); if (interpreters.isEmpty()) { return; } final Map<PythonInterpreterInfo, Sdk> interpreter2sdk = new HashMap<>(); /** * TODO(yic): to move it to a thread appropriate place. * * 1) testPyTestRunConfiguration(com.twitter.intellij.pants.execution.OSSPantsPythonRunConfigurationIntegrationTest) * com.intellij.testFramework.LoggedErrorProcessor$TestLoggerAssertionError: Can't update SDK under write action, not allowed in background */ //ExternalSystemApiUtil.executeProjectChangeAction(false, new DisposeAwareProjectChange(project) { // @Override // public void execute() { // for (final PythonInterpreterInfo interpreterInfo : interpreters) { // //final String binFolder = PathUtil.getParentPath(interpreter); // //final String interpreterHome = PathUtil.getParentPath(binFolder); // final String interpreter = interpreterInfo.getBinary(); // Sdk pythonSdk = PythonSdkType.findSdkByPath(interpreter); // if (pythonSdk == null) { // final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); // pythonSdk = jdkTable.createSdk(PathUtil.getFileName(interpreter), PythonSdkType.getInstance()); // jdkTable.addJdk(pythonSdk); // final SdkModificator modificator = pythonSdk.getSdkModificator(); // modificator.setHomePath(interpreter); // modificator.commitChanges(); // PythonSdkType.getInstance().setupSdkPaths(pythonSdk); // } // interpreter2sdk.put(interpreterInfo, pythonSdk); // } // } //}); for (DataNode<PythonSetupData> dataNode : toImport) { final PythonSetupData pythonSetupData = dataNode.getData(); final Sdk pythonSdk = interpreter2sdk.get(pythonSetupData.getInterpreterInfo()); final Module module = modelsProvider.findIdeModule(pythonSetupData.getOwnerModuleData()); if (module == null) { return; } FacetManager facetManager = FacetManager.getInstance(module); PythonFacet facet = facetManager.getFacetByType(PythonFacetType.getInstance().getId()); if (facet == null) { facet = facetManager.createFacet(PythonFacetType.getInstance(), "Python", null); facet.getConfiguration().setSdk(pythonSdk); final ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(module); facetModel.addFacet(facet); TestRunnerService.getInstance(module).setProjectConfiguration("py.test"); } } }