void (@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result, @NotNull PsiElement element, @NotNull PsiJavaCodeReferenceElement reference) { boolean inRefList = ReferenceListWeigher.INSIDE_REFERENCE_LIST.accepts(element); ElementFilter filter = getClassReferenceFilter(element, inRefList); if (filter != null) { final List<ExpectedTypeInfo> infos = Arrays.asList(getExpectedTypes(parameters)); for (LookupElement item : completeReference(element, reference, filter, true, false, parameters, result.getPrefixMatcher())) { Object o = item.getObject(); if (o instanceof PsiClass || CodeInsightSettings.getInstance().SHOW_PARAMETER_NAME_HINTS_ON_COMPLETION && JavaConstructorCallElement.isConstructorCallPlace(element) && o instanceof PsiMethod && ((PsiMethod)o).isConstructor()) { if (!inRefList && o instanceof PsiClass) { item = LookupElementDecorator.withInsertHandler(item, ConstructorInsertHandler.SMART_INSTANCE); } result.addElement(decorate(item, infos)); } } } else if (INSIDE_TYPECAST_EXPRESSION.accepts(element)) { final PsiTypeCastExpression cast = PsiTreeUtil.getContextOfType(element, PsiTypeCastExpression.class, true); if (cast != null && cast.getCastType() != null) { filter = new AssignableToFilter(cast.getCastType().getType()); for (final LookupElement item : completeReference(element, reference, filter, false, true, parameters, result.getPrefixMatcher())) { result.addElement(item); } } } }