@NotNull public static LineMarkerInfo createMethodSeparatorLineMarker(@NotNull PsiElement startFrom, @NotNull EditorColorsManager colorsManager) { LineMarkerInfo info = new LineMarkerInfo<PsiElement>( startFrom, startFrom.getTextRange(), null, Pass.UPDATE_ALL, 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; }
@RequiredReadAction @Override public void collect(PsiElement psiElement, @NotNull 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); } } } }
@Override @Nullable public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { if (myDaemonSettings.SHOW_METHOD_SEPARATORS) { if (element instanceof DylanDefinition) { LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.BOTTOM; return info; } } return null; }
@Nonnull public static LineMarkerInfo createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) { LineMarkerInfo 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; }
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) { super(methodCall, methodCall.getTextRange(), AllIcons.Gutter.RecursiveMethod, Pass.UPDATE_OVERRIDEN_MARKERS, FunctionUtil.<PsiMethodCallExpression, String>constant("Recursive call"), null, GutterIconRenderer.Alignment.RIGHT ); }
public CommonProblemDescriptorImpl(final QuickFix[] fixes, @NotNull 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; }
private FileTypeChooser(@NotNull List<String> patterns, @NotNull String fileName) { super(true); myFileName = fileName; myOpenInIdea.setText("Open matching files in " + ApplicationNamesInfo.getInstance().getFullProductName() + ":"); FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); Arrays.sort(fileTypes, new Comparator<FileType>() { @Override public int compare(final FileType fileType1, final FileType fileType2) { if (fileType1 == null) { return 1; } if (fileType2 == null) { return -1; } return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription()); } }); final DefaultListModel model = new DefaultListModel(); for (FileType type : fileTypes) { if (!type.isReadOnly() && type != FileTypes.UNKNOWN && !(type instanceof NativeFileType)) { model.addElement(type); } } myList.setModel(model); myPattern.setModel(new CollectionComboBoxModel(ContainerUtil.map(patterns, FunctionUtil.<String>id()), patterns.get(0))); setTitle(FileTypesBundle.message("filetype.chooser.title")); init(); }
@Nullable @Override public Color getFileColorFor(DefaultMutableTreeNode node) { if (!(node instanceof PackageDependenciesNode)) { return null; } return ProjectViewTree.getColorForObject(((PackageDependenciesNode)node).getPsiElement(), myProject, FunctionUtil.<PsiElement>id()); }
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); if (!(element instanceof PyTargetExpression)) return; final PyTargetExpression targetExpression = (PyTargetExpression)element; final PyClass containingClass = targetExpression.getContainingClass(); final PyAssignmentStatement assignment = PsiTreeUtil.getParentOfType(element, PyAssignmentStatement.class); if (containingClass == null || assignment == null) return; final Function<String, PyStatement> callback = FunctionUtil.<String, PyStatement>constant(assignment); AddFieldQuickFix.addFieldToInit(project, containingClass, ((PyTargetExpression)element).getName(), callback); removeDefinition(assignment); }
@Override public SearchForTestsTask createSearchingForTestsTask() { return new SearchForTestsTask(getProject(), myServerSocket) { @Override protected void search() throws ExecutionException { final Set<String> patterns = TestDiscoverySearchHelper.search(getProject(), getPosition(), getChangeList(), getFrameworkPrefix()); addClassesListToJavaParameters(patterns, FunctionUtil.<String>id(), "", false, getJavaParameters()); } @Override protected void onFound() {} }; }
@Nullable public static ArgInfo<PsiType>[] mapArgTypesToParameters(@NotNull GrClosureSignature signature, @NotNull PsiType[] args, @NotNull PsiElement context, boolean partial) { return mapParametersToArguments(signature, args, FunctionUtil.<PsiType>id(), context, partial); }
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; }
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<IdeaPluginDescriptor> 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(); }
public ChangesViewManager(@Nonnull Project project, @Nonnull ChangesViewContentManager 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(); } }); } }; }
@Override @Nullable public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) { PsiElement parent; if (element instanceof PsiIdentifier && (parent = element.getParent()) instanceof PsiMethod) { PsiMethod method = (PsiMethod)parent; MethodSignatureBackedByPsiMethod superSignature = SuperMethodsSearch.search(method, null, true, false).findFirst(); if (superSignature != null) { boolean overrides = method.hasModifierProperty(PsiModifier.ABSTRACT) == superSignature.getMethod().hasModifierProperty(PsiModifier.ABSTRACT); final Icon icon = overrides ? AllIcons.Gutter.OverridingMethod : AllIcons.Gutter.ImplementingMethod; return createSuperMethodLineMarkerInfo(element, icon, Pass.UPDATE_ALL); } } final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(element); final PsiElement firstChild = element.getFirstChild(); if (interfaceMethod != null && firstChild != null) { return createSuperMethodLineMarkerInfo(firstChild, AllIcons.Gutter.ImplementingFunctional, Pass.UPDATE_ALL); } if (myDaemonSettings.SHOW_METHOD_SEPARATORS && firstChild == null) { PsiElement element1 = element; boolean isMember = false; while (element1 != null && !(element1 instanceof PsiFile) && element1.getPrevSibling() == null) { element1 = element1.getParent(); if (element1 instanceof PsiMember) { isMember = true; break; } } if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) { PsiFile file = element1.getContainingFile(); Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getLastCommittedDocument(file); boolean drawSeparator = false; if (document != null) { CharSequence documentChars = document.getCharsSequence(); int category = getCategory(element1, documentChars); for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) { int category1 = getCategory(child, documentChars); if (category1 == 0) continue; drawSeparator = category != 1 || category1 != 1; break; } } if (drawSeparator) { LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; } } } return null; }
@NotNull @Override public Function<? super PsiElement, String> getCommonTooltip(@NotNull List<MergeableLineMarkerInfo> infos) { return FunctionUtil.nullConstant(); }
public List<VcsException> commit(List<Change> changes, String preparedComment) { return commit(changes, preparedComment, FunctionUtil.nullConstant(), null); }
public List<VcsException> commit(List<Change> changes, String preparedComment) { return commit(changes, preparedComment, FunctionUtil.<Object, Object>nullConstant(), null); }
@Nullable @Override public List<VcsException> commit(final List<Change> changes, final String preparedComment) { return commit(changes, preparedComment, FunctionUtil.<Object, Object>nullConstant(), null); }
@Override @Nullable public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) { PsiElement parent; if (element instanceof PsiIdentifier && (parent = element.getParent()) instanceof PsiMethod && !DumbService.getInstance(element.getProject()).isDumb()) { PsiMethod method = (PsiMethod)parent; MethodSignatureBackedByPsiMethod superSignature = SuperMethodsSearch.search(method, null, true, false).findFirst(); if (superSignature != null) { boolean overrides = method.hasModifierProperty(PsiModifier.ABSTRACT) == superSignature.getMethod().hasModifierProperty(PsiModifier.ABSTRACT); final Icon icon = overrides ? AllIcons.Gutter.OverridingMethod : AllIcons.Gutter.ImplementingMethod; final MarkerType type = MarkerType.OVERRIDING_METHOD; return new ArrowUpLineMarkerInfo(element, icon, type); } } if (myDaemonSettings.SHOW_METHOD_SEPARATORS && element.getFirstChild() == null) { PsiElement element1 = element; boolean isMember = false; while (element1 != null && !(element1 instanceof PsiFile) && element1.getPrevSibling() == null) { element1 = element1.getParent(); if (element1 instanceof PsiMember) { isMember = true; break; } } if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) { PsiFile file = element1.getContainingFile(); Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getDocument(file); boolean drawSeparator = false; if (document != null) { CharSequence documentChars = document.getCharsSequence(); int category = getCategory(element1, documentChars); for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) { int category1 = getCategory(child, documentChars); if (category1 == 0) continue; drawSeparator = category != 1 || category1 != 1; break; } } if (drawSeparator) { LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; } } } return null; }
@Override public Function<? super PsiElement, String> getCommonTooltip(@NotNull List<MergeableLineMarkerInfo> infos) { return FunctionUtil.nullConstant(); }
@RequiredReadAction @Nullable @Override public LineMarkerInfo getLineMarkerInfo(@NotNull 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(); }
@Nonnull @Override public Function<? super PsiElement, String> getCommonTooltip(@Nonnull List<MergeableLineMarkerInfo> infos) { return FunctionUtil.nullConstant(); }
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) { super(methodCall, methodCall.getTextRange(), AllIcons.Gutter.RecursiveMethod, Pass.LINE_MARKERS, FunctionUtil.constant("Recursive call"), null, GutterIconRenderer.Alignment.RIGHT); }