public static @Nullable Set<PsiType> getExpectedTypes(@NotNull CompletionParameters parameters) {
    PsiExpression expr = PsiTreeUtil.getContextOfType(parameters.getPosition(), PsiExpression.class, true);
    if (expr != null) {
      Set<PsiType> set = new HashSet<>();
      for (ExpectedTypeInfo expectedInfo : JavaSmartCompletionContributor.getExpectedTypes(parameters)) {
        set.add(expectedInfo.getType());
      }
      return set;
    }
    return null;
  }
public static @Nullable Set<PsiType> getExpectedTypes(@NotNull CompletionParameters parameters)