public static @NlsSafe String generateMethodInfo(PsiMethod method, PsiSubstitutor substitutor) {
    StringBuilder buffer = new StringBuilder();

    PsiClass parentClass = method.getContainingClass();

    JavaDocInfoGenerator docInfoGenerator = getDocInfoGenerator(method.getProject(), false);
    JavaDocHighlightingManagerImpl highlightingManager = JavaDocHighlightingManagerImpl.getInstance();

    if (parentClass != null && !(parentClass instanceof PsiAnonymousClass)) {
      if (method.isConstructor()) {
        generateOrderEntryAndPackageInfo(buffer, parentClass);
      }

      appendStyledSignatureFragment(
        buffer,
        JavaDocUtil.getShortestClassName(parentClass, method), highlightingManager.getClassDeclarationAttributes(parentClass)
      );
      newLine(buffer);
    }

    docInfoGenerator.generateTooltipAnnotations(method, buffer);
    generateModifiers(buffer, method);

    generateTypeParameters(method, buffer, highlightingManager);
    if (method.hasTypeParameters()) {
      buffer.append(" ");
    }

    if (method.getReturnType() != null) {
      docInfoGenerator.generateType(buffer, substitutor.substitute(method.getReturnType()), method, false, true);
      buffer.append(" ");
    }

    appendStyledSignatureFragment(buffer, method.getName(), highlightingManager.getMethodDeclarationAttributes(method));

    appendStyledSignatureFragment(buffer, "(", highlightingManager.getParenthesesAttributes());
    PsiParameter[] params = method.getParameterList().getParameters();
    for (int i = 0; i < params.length; i++) {
      PsiParameter param = params[i];
      docInfoGenerator.generateType(buffer, substitutor.substitute(param.getType()), method, false, true);
      buffer.append(" ");
      appendStyledSignatureFragment(buffer, param.getName(), highlightingManager.getParameterAttributes());
      if (i < params.length - 1) {
        appendStyledSignatureFragment(buffer, ", ", highlightingManager.getCommaAttributes());
      }
    }

    appendStyledSignatureFragment(buffer, ")", highlightingManager.getParenthesesAttributes());

    PsiClassType[] refs = method.getThrowsList().getReferencedTypes();
    if (refs.length > 0) {
      newLine(buffer);
      appendStyledSignatureFragment(buffer, " throws ", highlightingManager.getKeywordAttributes());
      for (int i = 0; i < refs.length; i++) {
        PsiClass throwsClass = refs[i].resolve();

        if (throwsClass != null) {
          appendStyledSignatureFragment(buffer, JavaDocUtil.getShortestClassName(throwsClass, method),
                                                                       highlightingManager.getClassDeclarationAttributes(throwsClass)
          );
        }
        else {
          buffer.append(refs[i].getPresentableText());
        }

        if (i < refs.length - 1) {
          appendStyledSignatureFragment(buffer, ", ", highlightingManager.getCommaAttributes());
        }
      }
    }

    return buffer.toString();
  }
public static @NlsSafe String generateMethodInfo(PsiMethod method, PsiSubstitutor substitutor)