MyResult (@NotNull LookupElement item) { final Object object = item.getObject(); if (object instanceof PsiClass) { if (object instanceof PsiTypeParameter) return MyResult.typeParameter; if (myTypeParameter != null && object.equals(PsiUtil.resolveClassInType(TypeConversionUtil.typeParameterErasure(myTypeParameter)))) { return MyResult.exactlyExpected; } } if (returnsUnboundType(item)) return MyResult.normal; PsiType itemType = JavaCompletionUtil.getLookupElementType(item); if ((myPreferExact || object instanceof PsiClass) && isExactlyExpected(item, itemType)) { return AbstractExpectedTypeSkipper.skips(item, myLocation) ? MyResult.expectedNoSelect : MyResult.exactlyExpected; } if (itemType == null) return MyResult.normal; for (final ExpectedTypeInfo expectedInfo : myExpectedTypes) { final PsiType defaultType = expectedInfo.getDefaultType(); final PsiType expectedType = expectedInfo.getType(); if (defaultType != expectedType) { if (myPreferExact && defaultType.equals(itemType)) { return MyResult.exactlyDefault; } if (defaultType.isAssignableFrom(itemType)) { return MyResult.ofDefaultType; } } if (PsiTypes.voidType().equals(itemType) && PsiTypes.voidType().equals(expectedType)) { return MyResult.exactlyExpected; } } return MyResult.normal; }