com.intellij.util.FunctionUtil Java Examples
The following examples show how to use
com.intellij.util.FunctionUtil.
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: RecursiveCallCollector.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction @Override public void collect(PsiElement psiElement, @Nonnull Consumer<LineMarkerInfo> consumer) { if(psiElement.getNode().getElementType() == CSharpTokens.IDENTIFIER && psiElement.getParent() instanceof CSharpReferenceExpression && psiElement.getParent().getParent() instanceof CSharpMethodCallExpressionImpl) { PsiElement resolvedElement = ((CSharpReferenceExpression) psiElement.getParent()).resolve(); if(resolvedElement instanceof CSharpMethodDeclaration) { CSharpMethodDeclaration methodDeclaration = PsiTreeUtil.getParentOfType(psiElement, CSharpMethodDeclaration.class); if(resolvedElement.isEquivalentTo(methodDeclaration)) { LineMarkerInfo<PsiElement> lineMarkerInfo = new LineMarkerInfo<PsiElement>(psiElement, psiElement.getTextRange(), AllIcons.Gutter.RecursiveMethod, Pass.LINE_MARKERS, FunctionUtil.constant("Recursive call"), null, GutterIconRenderer.Alignment.CENTER); consumer.consume(lineMarkerInfo); } } } }
Example #2
Source File: CommonProblemDescriptorImpl.java From consulo with Apache License 2.0 | 5 votes |
public CommonProblemDescriptorImpl(final QuickFix[] fixes, @Nonnull final String descriptionTemplate) { if (fixes == null) { myFixes = null; } else if (fixes.length == 0) { myFixes = QuickFix.EMPTY_ARRAY; } else { // no copy in most cases myFixes = ArrayUtil.contains(null, fixes) ? ContainerUtil.mapNotNull(fixes, FunctionUtil.<QuickFix>id(), QuickFix.EMPTY_ARRAY) : fixes; } myDescriptionTemplate = descriptionTemplate; }
Example #3
Source File: FileTypeChooser.java From consulo with Apache License 2.0 | 5 votes |
private FileTypeChooser(@Nonnull List<String> patterns, @Nonnull String fileName) { super(true); myFileName = fileName; FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); Arrays.sort(fileTypes, (fileType1, fileType2) -> { if (fileType1 == null) { return 1; } if (fileType2 == null) { return -1; } return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription()); }); final DefaultListModel<FileType> model = new DefaultListModel<>(); for (FileType type : fileTypes) { if (!type.isReadOnly() && type != UnknownFileType.INSTANCE && !(type instanceof NativeFileType)) { model.addElement(type); } } myList.setModel(model); myPattern.setModel(new CollectionComboBoxModel<>(ContainerUtil.map(patterns, FunctionUtil.<String>id()), patterns.get(0))); UnknownExtension fileFeatureForChecking = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), fileName); List<PluginDescriptor> allPlugins = PluginsAdvertiserHolder.getLoadedPluginDescriptors(); myFeaturePlugins = PluginsAdvertiser.findByFeature(allPlugins, fileFeatureForChecking); if (!myFeaturePlugins.isEmpty()) { myInstallPluginFromRepository.setSelected(true); myInstallPluginFromRepository.setText(FileTypesBundle.message("filetype.chooser.install.plugin")); } else { myInstallPluginFromRepository.setVisible(false); } setTitle(FileTypesBundle.message("filetype.chooser.title")); init(); }
Example #4
Source File: ChangesViewManager.java From consulo with Apache License 2.0 | 5 votes |
@Inject public ChangesViewManager(@Nonnull Project project, @Nonnull ChangesViewContentI contentManager) { myProject = project; myContentManager = contentManager; myView = new ChangesListView(project); myRepaintAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, project); myTsl = new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { if (LOG.isDebugEnabled()) { TreePath[] paths = myView.getSelectionPaths(); String joinedPaths = paths != null ? StringUtil.join(paths, FunctionUtil.string(), ", ") : null; String message = "selection changed. selected: " + joinedPaths; if (LOG.isTraceEnabled()) { LOG.trace(message + " from: " + DebugUtil.currentStackTrace()); } else { LOG.debug(message); } } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { changeDetails(); } }); } }; }
Example #5
Source File: LineMarkersPass.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static LineMarkerInfo<PsiElement> createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) { LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; }
Example #6
Source File: TFSCheckinEnvironment.java From azure-devops-intellij with MIT License | 4 votes |
public List<VcsException> commit(List<Change> changes, String preparedComment) { return commit(changes, preparedComment, FunctionUtil.<Object, Object>nullConstant(), null); }
Example #7
Source File: CSharpLineMarkerProvider.java From consulo-csharp with Apache License 2.0 | 4 votes |
@RequiredReadAction @Nullable @Override public LineMarkerInfo getLineMarkerInfo(@Nonnull PsiElement element) { if(myDaemonCodeAnalyzerSettings.SHOW_METHOD_SEPARATORS && (element instanceof DotNetQualifiedElement)) { if(element.getNode().getTreeParent() == null) { return null; } final PsiElement parent = element.getParent(); if(!(parent instanceof DotNetMemberOwner)) { return null; } if(ArrayUtil.getFirstElement(((DotNetMemberOwner) parent).getMembers()) == element) { return null; } LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myEditorColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; } final Ref<LineMarkerInfo> ref = Ref.create(); Consumer<LineMarkerInfo> consumer = new Consumer<LineMarkerInfo>() { @Override public void consume(LineMarkerInfo markerInfo) { ref.set(markerInfo); } }; //noinspection ForLoopReplaceableByForEach for(int j = 0; j < ourSingleCollector.length; j++) { LineMarkerCollector ourCollector = ourSingleCollector[j]; ourCollector.collect(element, consumer); } return ref.get(); }
Example #8
Source File: ColorLineMarkerProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Function<? super PsiElement, String> getCommonTooltip(@Nonnull List<MergeableLineMarkerInfo> infos) { return FunctionUtil.nullConstant(); }