Java Code Examples for com.intellij.util.NotNullFunction#fun()
The following examples show how to use
com.intellij.util.NotNullFunction#fun() .
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: LoadTextUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static FileType processTextFromBinaryPresentationOrNull(@Nonnull byte[] bytes, int length, @Nonnull VirtualFile virtualFile, boolean saveDetectedSeparators, boolean saveBOM, @Nonnull FileType fileType, @Nonnull NotNullFunction<? super CharSequence, ? extends FileType> fileTextProcessor) { DetectResult info = detectInternalCharsetAndSetBOM(virtualFile, bytes, length, saveBOM, fileType); Charset internalCharset = info.hardCodedCharset; CharsetToolkit.GuessedEncoding guessed = info.guessed; CharSequence toProcess; if (internalCharset == null || guessed == CharsetToolkit.GuessedEncoding.BINARY || guessed == CharsetToolkit.GuessedEncoding.INVALID_UTF8) { // the charset was not detected so the file is likely binary toProcess = null; } else { byte[] bom = info.BOM; int BOMEndOffset = Math.min(length, bom == null ? 0 : bom.length); ConvertResult result = convertBytes(bytes, BOMEndOffset, length, internalCharset); if (saveDetectedSeparators) { virtualFile.setDetectedLineSeparator(result.lineSeparator); } toProcess = result.text; } return fileTextProcessor.fun(toProcess); }
Example 2
Source File: ExecutionHelper.java From consulo with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: MockVcsContextFactory.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Deprecated @NotNull //@Override public FilePath createFilePathOn(@NotNull File file, @NotNull NotNullFunction<File, Boolean> notNullFunction) { return new IOFilePath(file, file.exists() ? file.isDirectory() : notNullFunction.fun(file) ); }
Example 4
Source File: JBLoadingPanel.java From consulo with Apache License 2.0 | 5 votes |
public JBLoadingPanel(@Nullable LayoutManager manager, @Nonnull NotNullFunction<? super JPanel, ? extends LoadingDecorator> createLoadingDecorator) { super(new BorderLayout()); myPanel = manager == null ? new JPanel() : new JPanel(manager); myPanel.setOpaque(false); myPanel.setFocusable(false); myDecorator = createLoadingDecorator.fun(myPanel); super.add(myDecorator.getComponent(), BorderLayout.CENTER); }
Example 5
Source File: PermanentLinearGraphBuilder.java From consulo with Apache License 2.0 | 5 votes |
private void fixUnderdoneEdges(@Nonnull NotNullFunction<CommitId, Integer> notLoadedCommitToId) { List<CommitId> commitIds = ContainerUtil.newArrayList(upAdjacentNodes.keySet()); ContainerUtil.sort(commitIds, new Comparator<CommitId>() { @Override public int compare(@Nonnull CommitId o1, @Nonnull CommitId o2) { return Collections.min(upAdjacentNodes.get(o1)) - Collections.min(upAdjacentNodes.get(o2)); } }); for (CommitId notLoadCommit : commitIds) { int notLoadId = notLoadedCommitToId.fun(notLoadCommit); for (int upNodeIndex : upAdjacentNodes.get(notLoadCommit)) { fixUnderdoneEdgeForNotLoadCommit(upNodeIndex, notLoadId); } } }
Example 6
Source File: CodeEditUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * Allows to answer if given node is configured to be reformatted. * * @param node node to check * @return {@code true} if given node is configured to be reformatted; {@code false} otherwise */ public static boolean isMarkedToReformat(final ASTNode node) { if (node.getCopyableUserData(REFORMAT_KEY) == null || !isSuspendedNodesReformattingAllowed()) { return false; } final NotNullFunction<ASTNode, Boolean> strategy = NODE_REFORMAT_STRATEGY.get(); return strategy == null || strategy.fun(node); }
Example 7
Source File: ChangesViewContentManager.java From consulo with Apache License 2.0 | 5 votes |
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) { myContentManager.removeContent(epContent, true); } } }
Example 8
Source File: ExecutionHelper.java From consulo with Apache License 2.0 | 5 votes |
public static List<RunContentDescriptor> collectConsolesByDisplayName(final Project project, @Nonnull NotNullFunction<String, Boolean> titleMatcher) { List<RunContentDescriptor> result = ContainerUtil.newArrayList(); final ExecutionManager executionManager = ExecutionManager.getInstance(project); for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) { if (titleMatcher.fun(runContentDescriptor.getDisplayName())) { result.add(runContentDescriptor); } } return result; }