List<LookupElement> (@NotNull CompletionParameters parameters, PsiElement position, PrefixMatcher matcher, PsiElement parent, @NotNull JavaCompletionSession session) { boolean smart = parameters.getCompletionType() == CompletionType.SMART; List<LookupElement> items = new ArrayList<>(); if (TypeArgumentCompletionProvider.IN_TYPE_ARGS.accepts(position)) { new TypeArgumentCompletionProvider(smart, session).addTypeArgumentVariants(parameters, items::add, matcher); } FunctionalExpressionCompletionProvider.addFunctionalVariants(parameters, false, matcher, items::add); if (MethodReturnTypeProvider.IN_METHOD_RETURN_TYPE.accepts(position)) { MethodReturnTypeProvider.addProbableReturnTypes(position, element -> { registerClassFromTypeElement(element, session); items.add(element); }); } suggestSmartCast(parameters, session, true, items::add); if (parent instanceof PsiReferenceExpression && !(parent instanceof PsiMethodReferenceExpression)) { List<ExpectedTypeInfo> expected = Arrays.asList(ExpectedTypesProvider.getExpectedTypes((PsiExpression)parent, true)); StreamConversion.addCollectConversion((PsiReferenceExpression)parent, expected, lookupElement -> items.add(JavaSmartCompletionContributor.decorate(lookupElement, expected))); if (!smart) { items.addAll(StreamConversion.addToStreamConversion((PsiReferenceExpression)parent, parameters)); } items.addAll(ArgumentSuggester.suggestArgument((PsiReferenceExpression)parent, smart ? expected : Collections.emptyList())); } if (IMPORT_REFERENCE.accepts(position)) { items.add(LookupElementBuilder.create("*")); } if (findAnnotationWhoseAttributeIsCompleted(position) == null) { items.addAll(new JavaKeywordCompletion(parameters, session, smart).getResults()); } addExpressionVariants(parameters, position, items::add); return items; }