/**
  * Build a list of multiline diagnostics containing detailed info about type-variables, captured
  * types, and intersection types
  *
  * @return where clause list
  */
 protected List<JCDiagnostic> getWhereClauses() {
   List<JCDiagnostic> clauses = List.nil();
   for (WhereClauseKind kind : WhereClauseKind.values()) {
     List<JCDiagnostic> lines = List.nil();
     for (Map.Entry<Type, JCDiagnostic> entry : whereClauses.get(kind).entrySet()) {
       lines = lines.prepend(entry.getValue());
     }
     if (!lines.isEmpty()) {
       String key = kind.key();
       if (lines.size() > 1) key += ".1";
       JCDiagnostic d = diags.fragment(key, whereClauses.get(kind).keySet());
       d = new JCDiagnostic.MultilineDiagnostic(d, lines.reverse());
       clauses = clauses.prepend(d);
     }
   }
   return clauses.reverse();
 }
 protected RichDiagnosticFormatter(Context context) {
   super((AbstractDiagnosticFormatter) Log.instance(context).getDiagnosticFormatter());
   setRichPrinter(new RichPrinter());
   this.syms = Symtab.instance(context);
   this.diags = JCDiagnostic.Factory.instance(context);
   this.types = Types.instance(context);
   this.messages = JavacMessages.instance(context);
   whereClauses = new LinkedHashMap<WhereClauseKind, Map<Type, JCDiagnostic>>();
   configuration = new RichConfiguration(Options.instance(context), formatter);
   for (WhereClauseKind kind : WhereClauseKind.values())
     whereClauses.put(kind, new LinkedHashMap<Type, JCDiagnostic>());
 }
 @Override
 public String format(JCDiagnostic diag, Locale l) {
   StringBuilder sb = new StringBuilder();
   nameSimplifier = new ClassNameSimplifier();
   for (WhereClauseKind kind : WhereClauseKind.values()) whereClauses.get(kind).clear();
   preprocessDiagnostic(diag);
   sb.append(formatter.format(diag, l));
   if (getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) {
     List<JCDiagnostic> clauses = getWhereClauses();
     String indent = formatter.isRaw() ? "" : formatter.indentString(DetailsInc);
     for (JCDiagnostic d : clauses) {
       String whereClause = formatter.format(d, l);
       if (whereClause.length() > 0) {
         sb.append('\n' + indent + whereClause);
       }
     }
   }
   return sb.toString();
 }