private static List<PsiType[]> inferExpectedSignatures(@NotNull GroovyResolveResult variant,
                                                         @NotNull GrMethodCall call,
                                                         @NotNull GrFunctionalExpression expression) {
    PsiElement element = variant.getElement();

    while (element instanceof PsiMirrorElement) element = ((PsiMirrorElement)element).getPrototype();
    if (!(element instanceof PsiMethod)) return Collections.emptyList();

    PsiParameter param = null;
    if (variant instanceof GroovyMethodResult) {
      GroovyMethodCandidate candidate = ((GroovyMethodResult)variant).getCandidate();
      if (candidate != null) {
        ArgumentMapping<PsiCallParameter> mapping = candidate.getArgumentMapping();
        if (mapping != null) {
          PsiCallParameter obj = mapping.targetParameter(new ExpressionArgument(expression));
          param = obj == null ? null : obj.getPsi();
        }
      }
    } else {
      List<Pair<PsiParameter, PsiType>> params = ResolveUtil.collectExpectedParamsByArg(expression, //TODO:Replace with new api
                                                                                        new GroovyResolveResult[]{variant},
                                                                                        call.getNamedArguments(),
                                                                                        call.getExpressionArguments(),
                                                                                        call.getClosureArguments(), expression);
      if (params.isEmpty()) return Collections.emptyList();

      Pair<PsiParameter, PsiType> pair = params.get(0);

      param = pair.getFirst();
    }
    if (param == null) return Collections.emptyList();

    PsiModifierList modifierList = param.getModifierList();
    if (modifierList == null) return Collections.emptyList();

    PsiAnnotation anno = modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_STC_CLOSURE_PARAMS);
    if (anno == null) return Collections.emptyList();

    PsiClass closureSignatureHint = GrAnnotationUtil.inferClassAttribute(anno, "value");
    if (closureSignatureHint == null) return Collections.emptyList();

    String qnameOfClosureSignatureHint = closureSignatureHint.getQualifiedName();
    if (qnameOfClosureSignatureHint == null) return Collections.emptyList();

    SignatureHintProcessor signatureHintProcessor = SignatureHintProcessor.getHintProcessor(qnameOfClosureSignatureHint);
    if (signatureHintProcessor == null) return Collections.emptyList();

    PsiSubstitutor substitutor = null;
    if (variant instanceof GroovyMethodResult) {
      GroovyMethodCandidate candidate = ((GroovyMethodResult)variant).getCandidate();
      if (candidate != null) {
        GroovyInferenceSessionBuilder builder = new GroovyInferenceSessionBuilder(call, candidate, variant.getContextSubstitutor());
        substitutor = computeAnnotationBasedSubstitutor(call, builder);
      }
    }
    if (substitutor == null ) {
      substitutor = variant.getSubstitutor();
    }

    return signatureHintProcessor.inferExpectedSignatures((PsiMethod)element, substitutor, SignatureHintProcessor.buildOptions(anno));
  }
private static List<PsiType[]> inferExpectedSignatures(@NotNull GroovyResolveResult variant,
                                                         @NotNull GrMethodCall call,
                                                         @NotNull GrFunctionalExpression expression)