public static void appendParameterPresentation(
    GrParameter parameter,
    PsiSubstitutor substitutor,
    TypePresentation typePresentation,
    StringBuilder builder,
    boolean doHighlighting
  ) {
    if (presentNamedParameters(builder, parameter, doHighlighting)) return;

    for (PsiAnnotation annotation : parameter.getModifierList().getAnnotations()) {
      appendStyledSpan(doHighlighting, builder, GroovySyntaxHighlighter.ANNOTATION, annotation.getText());
      builder.append(' ');
    }

    PsiType type = parameter.getTypeGroovy();
    type = substitutor.substitute(type);

    if (typePresentation == TypePresentation.LINK) {
      if (type != null) {
        StringBuilder typeBuilder = new StringBuilder();
        JavaDocInfoGeneratorFactory.create(parameter.getProject(), null).generateType(typeBuilder, type, parameter);
        if (doHighlighting) {
          builder.append(typeBuilder);
        }
        else {
          builder.append(StringUtil.removeHtmlTags(typeBuilder.toString(), true));
        }
      }
      else {
        appendStyledSpan(doHighlighting, builder, GroovySyntaxHighlighter.KEYWORD, GrModifier.DEF);
      }
      builder.append(' ');
      appendStyledSpan(doHighlighting, builder, GroovySyntaxHighlighter.PARAMETER, parameter.getName());
      return;
    }

    if (type != null) {
      if (typePresentation == TypePresentation.PRESENTABLE) {
        builder.append(type.getPresentableText()).append(' ').append(parameter.getName());
      }
      else if (typePresentation == TypePresentation.CANONICAL) {
        builder.append(type.getCanonicalText()).append(' ').append(parameter.getName());
      }
    }
    else {
      builder.append(parameter.getName());
      final Set<String> structural = Collections.synchronizedSet(new LinkedHashSet<>());
      ReferencesSearch.search(parameter, parameter.getUseScope()).forEach(ref -> {
        PsiElement parent = ref.getElement().getParent();
        if (parent instanceof GrReferenceExpression) {

          if (structural.size() >= CONSTRAINTS_NUMBER) { //handle too many constraints
            structural.add("...");
            return false;
          }

          StringBuilder builder1 = new StringBuilder();
          builder1.append(((GrReferenceElement<?>)parent).getReferenceName());
          PsiType[] argTypes = PsiUtil.getArgumentTypes(parent, true);
          if (argTypes != null) {
            builder1.append("(");
            builder1.append(GroovyBundle.message("parameter.hint.number.of.arguments", argTypes.length));
            builder1.append(')');
          }

          structural.add(builder1.toString());
        }

        return true;
      });

      if (!structural.isEmpty()) {
        builder.append(".");
        String[] array = ArrayUtilRt.toStringArray(structural);
        if (array.length > 1) builder.append("[");
        for (int i = 0; i < array.length; i++) {
          if (i > 0) builder.append(", ");
          builder.append(array[i]);
        }
        if (array.length > 1) builder.append("]");
      }
    }
  }
public static void appendParameterPresentation(
    GrParameter parameter,
    PsiSubstitutor substitutor,
    TypePresentation typePresentation,
    StringBuilder builder,
    boolean doHighlighting
  )