com.intellij.util.NullableFunction Java Examples
The following examples show how to use
com.intellij.util.NullableFunction.
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: CommitHelper.java From consulo with Apache License 2.0 | 6 votes |
public CommitHelper(final Project project, final ChangeList changeList, final List<Change> includedChanges, final String actionName, final String commitMessage, final List<CheckinHandler> handlers, final boolean allOfDefaultChangeListChangesIncluded, final boolean synchronously, final NullableFunction<Object, Object> additionalDataHolder, @Nullable CommitResultHandler customResultHandler) { myProject = project; myChangeList = changeList; myIncludedChanges = includedChanges; myActionName = actionName; myCommitMessage = commitMessage; myHandlers = handlers; myAllOfDefaultChangeListChangesIncluded = allOfDefaultChangeListChangesIncluded; myForceSyncCommit = synchronously; myAdditionalData = additionalDataHolder; myCustomResultHandler = customResultHandler; myConfiguration = VcsConfiguration.getInstance(myProject); myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject); myFeedback = new HashSet<String>(); }
Example #2
Source File: DvcsTaskHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private List<R> getRepositories(@Nonnull Collection<String> urls) { final List<R> repositories = myRepositoryManager.getRepositories(); return ContainerUtil.mapNotNull(urls, new NullableFunction<String, R>() { @Nullable @Override public R fun(final String s) { return ContainerUtil.find(repositories, new Condition<R>() { @Override public boolean value(R repository) { return s.equals(repository.getPresentableUrl()); } }); } }); }
Example #3
Source File: SdkComboBox.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction @SuppressWarnings("unchecked") public <T extends MutableModuleExtension<?>> void insertModuleItems(@Nonnull T moduleExtension, @Nonnull NullableFunction<T, MutableModuleInheritableNamedPointer<Sdk>> sdkPointerFunction) { for (Module module : ModuleManager.getInstance(moduleExtension.getModule().getProject()).getModules()) { // dont add self module if (module == moduleExtension.getModule()) { continue; } ModuleExtension extension = ModuleUtilCore.getExtension(module, moduleExtension.getId()); if (extension == null) { continue; } MutableModuleInheritableNamedPointer<Sdk> sdkPointer = sdkPointerFunction.fun((T)extension); if (sdkPointer != null) { // recursive depend if (sdkPointer.getModule() == moduleExtension.getModule()) { continue; } addItem(new ModuleExtensionSdkComboBoxItem(extension, sdkPointer)); } } }
Example #4
Source File: ZipUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void unzip(@Nullable ProgressIndicator progress, File extractToDir, ZipInputStream stream, @Nullable NullableFunction<String, String> pathConvertor, @Nullable ContentProcessor contentProcessor) throws IOException { if (progress != null) { progress.setText("Extracting..."); } try { ZipEntry entry; while ((entry = stream.getNextEntry()) != null) { unzipEntryToDir(progress, entry, extractToDir, stream, pathConvertor, contentProcessor); } } finally { stream.close(); } }
Example #5
Source File: SemServiceImpl.java From consulo with Apache License 2.0 | 6 votes |
private MultiMap<SemKey, NullableFunction<PsiElement, ? extends SemElement>> collectProducers() { final MultiMap<SemKey, NullableFunction<PsiElement, ? extends SemElement>> map = MultiMap.createSmart(); final SemRegistrar registrar = new SemRegistrar() { @Override public <T extends SemElement, V extends PsiElement> void registerSemElementProvider(SemKey<T> key, final ElementPattern<? extends V> place, final NullableFunction<V, T> provider) { map.putValue(key, element -> { if (place.accepts(element)) { return provider.fun((V)element); } return null; }); } }; for (SemContributorEP contributor : myProject.getExtensions(SemContributor.EP_NAME)) { contributor.registerSemProviders(myProject.getInjectingContainer(), registrar); } return map; }
Example #6
Source File: SemServiceImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private List<SemElement> createSemElements(SemKey key, PsiElement psi) { List<SemElement> result = null; final Collection<NullableFunction<PsiElement, ? extends SemElement>> producers = myProducers.get(key); if (!producers.isEmpty()) { for (final NullableFunction<PsiElement, ? extends SemElement> producer : producers) { myCreatingSem.incrementAndGet(); try { final SemElement element = producer.fun(psi); if (element != null) { if (result == null) result = new SmartList<>(); result.add(element); } } finally { myCreatingSem.decrementAndGet(); } } } return result == null ? Collections.emptyList() : Collections.unmodifiableList(result); }
Example #7
Source File: VcsHandleType.java From consulo with Apache License 2.0 | 5 votes |
public VcsHandleType(AbstractVcs vcs) { super(VcsBundle.message("handle.ro.file.status.type.using.vcs", vcs.getDisplayName()), true); myVcs = vcs; myChangeListManager = ChangeListManager.getInstance(myVcs.getProject()); myChangeFunction = new NullableFunction<VirtualFile, Change>() { @Override public Change fun(VirtualFile file) { return myChangeListManager.getChange(file); } }; }
Example #8
Source File: FileChooserUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static List<VirtualFile> getChosenFiles(@Nonnull final FileChooserDescriptor descriptor, @Nonnull final Collection<VirtualFile> selectedFiles) { return ContainerUtil.mapNotNull(selectedFiles, new NullableFunction<VirtualFile, VirtualFile>() { @Override public VirtualFile fun(final VirtualFile file) { return file != null && file.isValid() ? descriptor.getFileToSelect(file) : null; } }); }
Example #9
Source File: NavigationGutterIconRenderer.java From consulo with Apache License 2.0 | 5 votes |
public List<PsiElement> getTargetElements() { return ContainerUtil.mapNotNull(myPointers.getValue(), new NullableFunction<SmartPsiElementPointer, PsiElement>() { public PsiElement fun(final SmartPsiElementPointer smartPsiElementPointer) { return smartPsiElementPointer.getElement(); } }); }
Example #10
Source File: PsiFileGistImpl.java From consulo with Apache License 2.0 | 5 votes |
PsiFileGistImpl(@Nonnull String id, int version, @Nonnull DataExternalizer<Data> externalizer, @Nonnull NullableFunction<PsiFile, Data> calculator) { myCalculator = (project, file) -> { PsiFile psiFile = getPsiFile(project, file); return psiFile == null ? null : calculator.fun(psiFile); }; myPersistence = GistManager.getInstance().newVirtualFileGist(id, version, externalizer, myCalculator); myCacheKey = Key.create("PsiFileGist " + id); }
Example #11
Source File: ExternalSystemApiUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static <K, V> Map<K, List<V>> groupBy(@Nonnull Collection<V> nodes, @Nonnull NullableFunction<V, K> grouper) { Map<K, List<V>> result = ContainerUtilRt.newHashMap(); for (V data : nodes) { K key = grouper.fun(data); if (key == null) { LOG.warn(String.format( "Skipping entry '%s' during grouping. Reason: it's not possible to build a grouping key with grouping strategy '%s'. " + "Given entries: %s", data, grouper.getClass(), nodes)); continue; } List<V> grouped = result.get(key); if (grouped == null) { result.put(key, grouped = ContainerUtilRt.newArrayList()); } grouped.add(data); } if (!result.isEmpty() && result.keySet().iterator().next() instanceof Comparable) { List<K> ordered = ContainerUtilRt.newArrayList(result.keySet()); Collections.sort(ordered, COMPARABLE_GLUE); Map<K, List<V>> orderedResult = ContainerUtilRt.newLinkedHashMap(); for (K k : ordered) { orderedResult.put(k, result.get(k)); } return orderedResult; } return result; }
Example #12
Source File: ExternalSystemApiUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static <K, V> Map<DataNode<K>, List<DataNode<V>>> groupBy(@Nonnull Collection<DataNode<V>> nodes, @Nonnull final Key<K> key) { return groupBy(nodes, new NullableFunction<DataNode<V>, DataNode<K>>() { @Nullable @Override public DataNode<K> fun(DataNode<V> node) { return node.getDataNode(key); } }); }
Example #13
Source File: SubmitModel.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Nullable public static JobStatus getSubmitStatus(@NotNull NullableFunction<Object, Object> dataSupplier) { final Object ret = dataSupplier.fun("jobStatus"); if (ret != null) { return (JobStatus) ret; } return null; }
Example #14
Source File: SubmitModel.java From p4ic4idea with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static List<P4Job> getJobs(@NotNull NullableFunction<Object, Object> dataSupplier) { Object ret = dataSupplier.fun("jobIds"); if (ret != null) { return (List<P4Job>) ret; } return Collections.emptyList(); }
Example #15
Source File: P4CheckinEnvironment.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Nullable @Override public List<VcsException> commit(List<Change> changes, final String preparedComment, @NotNull NullableFunction<Object, Object> parametersHolder, Set<String> feedback) { return CommitUtil.commit(project, changes, preparedComment, SubmitModel.getJobs(parametersHolder), SubmitModel.getSubmitStatus(parametersHolder)); }
Example #16
Source File: PsalmValidatorConfigurationProvider.java From idea-php-generics-plugin with MIT License | 5 votes |
protected void fillSettingsByDefaultValue(@NotNull PsalmValidatorConfiguration settings, @NotNull PsalmValidatorConfiguration localConfiguration, @NotNull NullableFunction<String, String> preparePath) { super.fillSettingsByDefaultValue(settings, localConfiguration, preparePath); String toolPath = preparePath.fun(localConfiguration.getToolPath()); if (StringUtil.isNotEmpty(toolPath)) { settings.setToolPath(toolPath); } settings.setTimeout(localConfiguration.getTimeout()); }
Example #17
Source File: PhpStanValidatorConfigurationProvider.java From idea-php-generics-plugin with MIT License | 5 votes |
protected void fillSettingsByDefaultValue(@NotNull PhpStanValidatorConfiguration settings, @NotNull PhpStanValidatorConfiguration localConfiguration, @NotNull NullableFunction<String, String> preparePath) { super.fillSettingsByDefaultValue(settings, localConfiguration, preparePath); String toolPath = preparePath.fun(localConfiguration.getToolPath()); if (StringUtil.isNotEmpty(toolPath)) { settings.setToolPath(toolPath); } settings.setTimeout(localConfiguration.getTimeout()); }
Example #18
Source File: NavigationGutterIconBuilder.java From consulo with Apache License 2.0 | 4 votes |
protected NullableFunction<T,String> createDefaultNamer() { return DEFAULT_NAMER; }
Example #19
Source File: NavigationGutterIconBuilder.java From consulo with Apache License 2.0 | 4 votes |
public NavigationGutterIconBuilder<T> setNamer(@Nonnull NullableFunction<T,String> namer) { myNamer = namer; return this; }
Example #20
Source File: ModuleExtensionSdkBoxBuilder.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @UsedInPlugin public ModuleExtensionSdkBoxBuilder<T> sdkPointerFunc(@Nonnull NullableFunction<T, MutableModuleInheritableNamedPointer<Sdk>> function) { mySdkPointerFunction = function; return this; }
Example #21
Source File: ChangelistConflictTracker.java From consulo with Apache License 2.0 | 4 votes |
public Collection<String> getIgnoredConflicts() { return ContainerUtil.mapNotNull(myConflicts.entrySet(), (NullableFunction<Map.Entry<String, Conflict>, String>)entry -> entry.getValue().ignored ? entry.getKey() : null); }
Example #22
Source File: GistManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public <Data> PsiFileGist<Data> newPsiFileGist(@Nonnull String id, int version, @Nonnull DataExternalizer<Data> externalizer, @Nonnull NullableFunction<PsiFile, Data> calculator) { return new PsiFileGistImpl<>(id, version, externalizer, calculator); }
Example #23
Source File: CheckinEnvironment.java From consulo with Apache License 2.0 | 4 votes |
@javax.annotation.Nullable List<VcsException> commit(List<Change> changes, String preparedComment, @Nonnull NullableFunction<Object, Object> parametersHolder, Set<String> feedback);
Example #24
Source File: NullableLazyKey.java From consulo with Apache License 2.0 | 4 votes |
public static <T,H extends UserDataHolder> NullableLazyKey<T,H> create(@NonNls String name, final NullableFunction<H, T> function) { return new NullableLazyKey<T,H>(name, function); }
Example #25
Source File: NullableLazyKey.java From consulo with Apache License 2.0 | 4 votes |
private NullableLazyKey(@NonNls String name, final NullableFunction<H, T> function) { super(name); myFunction = function; }
Example #26
Source File: ActionUpdater.java From consulo with Apache License 2.0 | 4 votes |
UpdateStrategy(NullableFunction<AnAction, Presentation> update, NotNullFunction<ActionGroup, AnAction[]> getChildren, Predicate<ActionGroup> canBePerformed) { this.update = update; this.getChildren = getChildren; this.canBePerformed = canBePerformed; }
Example #27
Source File: NonProjectFileWritingAccessProvider.java From consulo with Apache License 2.0 | 4 votes |
@TestOnly public static void setCustomUnlocker(@Nullable NullableFunction<List<VirtualFile>, UnlockOption> unlocker) { ourCustomUnlocker = unlocker; }
Example #28
Source File: FileReferenceSet.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected Collection<PsiFileSystemItem> toFileSystemItems(@Nonnull Collection<VirtualFile> files) { final PsiManager manager = getElement().getManager(); return ContainerUtil.mapNotNull(files, (NullableFunction<VirtualFile, PsiFileSystemItem>)file -> file != null ? manager.findDirectory(file) : null); }
Example #29
Source File: IdeaGateway.java From consulo with Apache License 2.0 | 4 votes |
private void doCreateChildren(@Nonnull DirectoryEntry parent, Iterable<VirtualFile> children, final boolean forDeletion) { List<Entry> entries = ContainerUtil.mapNotNull(children, (NullableFunction<VirtualFile, Entry>)each -> doCreateEntry(each, forDeletion)); parent.addChildren(entries); }
Example #30
Source File: VirtualFileVisitorTest.java From consulo with Apache License 2.0 | 4 votes |
@Test public void customIterable() { doTest( null, new NullableFunction<VirtualFile, Iterable<VirtualFile>>() { @Override public Iterable<VirtualFile> fun(VirtualFile file) { return "d13".equals(file.getName()) ? Collections.singletonList(file.getChildren()[1]) : null; } }, "-> / [0]\n" + " -> d1 [1]\n" + " -> d11 [2]\n" + " -> f11.1 [3]\n" + " <- f11.1 [4]\n" + " -> f11.2 [3]\n" + " <- f11.2 [4]\n" + " <- d11 [3]\n" + " -> f1.1 [2]\n" + " <- f1.1 [3]\n" + " -> d12 [2]\n" + " <- d12 [3]\n" + " -> d13 [2]\n" + " -> f13.2 [3]\n" + " <- f13.2 [4]\n" + " <- d13 [3]\n" + " -> d11_link [2]\n" + " -> f11.1 [3]\n" + " <- f11.1 [4]\n" + " -> f11.2 [3]\n" + " <- f11.2 [4]\n" + " <- d11_link [3]\n" + " <- d1 [2]\n" + " -> d2 [1]\n" + " -> f2.1 [2]\n" + " <- f2.1 [3]\n" + " -> f2.2 [2]\n" + " <- f2.2 [3]\n" + " <- d2 [2]\n" + " -> d3 [1]\n" + " -> d3_rec_link [2]\n" + " <- d3_rec_link [3]\n" + " <- d3 [2]\n" + "<- / [1]\n"); }