boolean (Object element, SearchEverywhereContributor<?> contributor, int priority, ProgressIndicator indicator) { assert contributor == myExpandedContributor; // Only expanded contributor items allowed Collection<SearchEverywhereFoundElementInfo> section = sections.get(contributor); final var mlService = SearchEverywhereMlService.getInstance(); final SearchEverywhereFoundElementInfo newElementInfo; if (mlService == null) { newElementInfo = new SearchEverywhereFoundElementInfo(element, priority, contributor); } else { newElementInfo = mlService.createFoundElementInfo(contributor, element, priority); } if (section.size() >= myNewLimit) { return false; } List<SearchEverywhereFoundElementInfo> alreadyFoundItems = sections.values() .stream() .flatMap(Collection::stream) .collect(Collectors.toList()); SEEqualElementsActionType action = myEqualityProvider.compareItems(newElementInfo, alreadyFoundItems); if (action == SEEqualElementsActionType.Skip.INSTANCE) { LOG.debug(String.format("Element %s for contributor %s was skipped", element.toString(), contributor.getSearchProviderId())); return true; } section.add(newElementInfo); runInNotificationExecutor(() -> myListener.elementsAdded(Collections.singletonList(newElementInfo))); List<SearchEverywhereFoundElementInfo> toRemove = action instanceof SEEqualElementsActionType.Replace ? ((SEEqualElementsActionType.Replace)action).getToBeReplaced() : Collections.emptyList(); toRemove.forEach(info -> { Collection<SearchEverywhereFoundElementInfo> list = sections.get(info.getContributor()); if (list != null) { list.remove(info); LOG.debug(String.format("Element %s for contributor %s is removed", info.getElement().toString(), info.getContributor().getSearchProviderId())); } }); runInNotificationExecutor(() -> myListener.elementsRemoved(toRemove)); return true; }