private static @Nullable String getTailText(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) {
    if (element instanceof PsiMethod) {
      PsiClass aClass = ((PsiMethod)element).getContainingClass();
      if (aClass != null && aClass.isAnnotationType()) {
        return null;
      }
      return PsiFormatUtil.formatMethod((PsiMethod)element, substitutor, PsiFormatUtilBase.SHOW_PARAMETERS,
                                        PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE);
    }
    else if (element instanceof PsiClass psiClass) {
      String tailText = getPackageText(psiClass);
      if (substitutor.getSubstitutionMap().isEmpty() && psiClass.getTypeParameters().length > 0) {
        tailText = "<" +
                   StringUtil.join(psiClass.getTypeParameters(), psiTypeParameter -> psiTypeParameter.getName(),
                                   "," + (showSpaceAfterComma(psiClass) ? " " : "")) +
                   ">" +
                   tailText;
      }
      return tailText;
    }
    return null;
  }
private static @Nullable String getTailText(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor)