void (CompletionParameters parameters, CompletionResultSet result, @Nullable JavaCompletionSession session) { List<LookupElement> sameNamedBatch = new ArrayList<>(); PsiElement position = parameters.getPosition(); JavaLookupElementHighlighter highlighter = JavaCompletionUtil.getHighlighterForPlace(position); JavaClassNameCompletionContributor.addAllClasses(parameters, parameters.getInvocationCount() <= 2, result.getPrefixMatcher(), element -> { if (session != null && session.alreadyProcessed(element)) { return; } JavaPsiClassReferenceElement classElement = element.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY); if (classElement != null && parameters.getInvocationCount() < 2) { if (JavaClassNameCompletionContributor.AFTER_NEW.accepts(position) && JavaPsiClassReferenceElement.isInaccessibleConstructorSuggestion(position, classElement.getObject())) { return; } classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE); } element = highlighter.highlightIfNeeded(null, element, element.getObject()); if (!sameNamedBatch.isEmpty() && !element.getLookupString().equals(sameNamedBatch.get(0).getLookupString())) { result.addAllElements(sameNamedBatch); sameNamedBatch.clear(); } sameNamedBatch.add(element); }); result.addAllElements(sameNamedBatch); }