void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { try { if (!Registry.is(REGISTRY_KEY)) return; final Set<PsiMethod> alreadySuggested = new HashSet<>(); CompletionResultSet finalResult = result; result.runRemainingContributors(parameters, completionResult -> { LookupElement lookupElement = completionResult.getLookupElement(); PsiElement psi = lookupElement.getPsiElement(); if (psi instanceof PsiMethod) { alreadySuggested.add((PsiMethod)psi); } finalResult.passResult(completionResult); }); ChainCompletionContext completionContext = extractContext(parameters); if (completionContext == null) return; result = JavaCompletionSorting.addJavaSorting(parameters, result); List<LookupElement> elementsFoundByMethodsChainsSearch = searchForLookups(completionContext); if (!UNIT_TEST_MODE && !alreadySuggested.isEmpty()) { elementsFoundByMethodsChainsSearch = ContainerUtil.filter(elementsFoundByMethodsChainsSearch, lookupElement -> { PsiElement psi = lookupElement.getPsiElement(); return !(psi instanceof PsiMethod) || !alreadySuggested.contains(psi); }); } result.addAllElements(elementsFoundByMethodsChainsSearch); } catch (ReferenceIndexUnavailableException ignored) { //index was closed due to compilation } }