/**
   * Check that function or property with the given qualified name can be resolved in given scope
   * and called on given receiver
   *
   * @param callableFQN
   * @param project
   * @param scope
   * @return
   */
  public static List<CallableDescriptor> canFindSuitableCall(
      @NotNull FqName callableFQN,
      @NotNull Project project,
      @NotNull JetExpression receiverExpression,
      @NotNull JetType receiverType,
      @NotNull JetScope scope) {

    JetImportDirective importDirective =
        JetPsiFactory.createImportDirective(project, callableFQN.getFqName());

    Collection<? extends DeclarationDescriptor> declarationDescriptors =
        ImportsResolver.analyseImportReference(importDirective, scope, new BindingTraceContext());

    List<CallableDescriptor> callableExtensionDescriptors = new ArrayList<CallableDescriptor>();
    ReceiverDescriptor receiverDescriptor =
        new ExpressionReceiver(receiverExpression, receiverType);

    for (DeclarationDescriptor declarationDescriptor : declarationDescriptors) {
      if (declarationDescriptor instanceof CallableDescriptor) {
        CallableDescriptor callableDescriptor = (CallableDescriptor) declarationDescriptor;

        if (checkIsExtensionCallable(receiverDescriptor, callableDescriptor)) {
          callableExtensionDescriptors.add(callableDescriptor);
        }
      }
    }

    return callableExtensionDescriptors;
  }
 @NotNull
 public static JetExpression createStubExpressionOfNecessaryType(
     @NotNull Project project, @NotNull JetType type, @NotNull BindingTrace trace) {
   JetExpression expression = JetPsiFactory.createExpression(project, "$e");
   trace.record(PROCESSED, expression);
   trace.record(EXPRESSION_TYPE, expression, type);
   return expression;
 }
 public static boolean isVariableIterable(
     @NotNull ExpressionTypingServices expressionTypingServices,
     @NotNull Project project,
     @NotNull VariableDescriptor variableDescriptor,
     @NotNull JetScope scope) {
   JetExpression expression = JetPsiFactory.createExpression(project, "fake");
   ExpressionReceiver expressionReceiver =
       new ExpressionReceiver(expression, variableDescriptor.getType());
   ExpressionTypingContext context =
       ExpressionTypingContext.newContext(
           expressionTypingServices,
           new HashMap<JetPattern, DataFlowInfo>(),
           new HashMap<JetPattern, List<VariableDescriptor>>(),
           new LabelResolver(),
           new BindingTraceContext(),
           scope,
           DataFlowInfo.EMPTY,
           TypeUtils.NO_EXPECTED_TYPE,
           TypeUtils.NO_EXPECTED_TYPE,
           false);
   return ControlStructureTypingVisitor.checkIterableConvention(expressionReceiver, context)
       != null;
 }