langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java
changeset 22163 3651128c74eb
parent 18900 5ed5dd2ee5fe
child 22165 ec53c8946fc2
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    95         setRichPrinter(new RichPrinter());
    95         setRichPrinter(new RichPrinter());
    96         this.syms = Symtab.instance(context);
    96         this.syms = Symtab.instance(context);
    97         this.diags = JCDiagnostic.Factory.instance(context);
    97         this.diags = JCDiagnostic.Factory.instance(context);
    98         this.types = Types.instance(context);
    98         this.types = Types.instance(context);
    99         this.messages = JavacMessages.instance(context);
    99         this.messages = JavacMessages.instance(context);
   100         whereClauses = new EnumMap<WhereClauseKind, Map<Type, JCDiagnostic>>(WhereClauseKind.class);
   100         whereClauses = new EnumMap<>(WhereClauseKind.class);
   101         configuration = new RichConfiguration(Options.instance(context), formatter);
   101         configuration = new RichConfiguration(Options.instance(context), formatter);
   102         for (WhereClauseKind kind : WhereClauseKind.values())
   102         for (WhereClauseKind kind : WhereClauseKind.values())
   103             whereClauses.put(kind, new LinkedHashMap<Type, JCDiagnostic>());
   103             whereClauses.put(kind, new LinkedHashMap<>());
   104     }
   104     }
   105 
   105 
   106     @Override
   106     @Override
   107     public String format(JCDiagnostic diag, Locale l) {
   107     public String format(JCDiagnostic diag, Locale l) {
   108         StringBuilder sb = new StringBuilder();
   108         StringBuilder sb = new StringBuilder();
   277      * to fullnames as compact names might lead to a confusing diagnostic.
   277      * to fullnames as compact names might lead to a confusing diagnostic.
   278      */
   278      */
   279     protected class ClassNameSimplifier {
   279     protected class ClassNameSimplifier {
   280 
   280 
   281         /* table for keeping track of all short name usages */
   281         /* table for keeping track of all short name usages */
   282         Map<Name, List<Symbol>> nameClashes = new HashMap<Name, List<Symbol>>();
   282         Map<Name, List<Symbol>> nameClashes = new HashMap<>();
   283 
   283 
   284         /**
   284         /**
   285          * Add a name usage to the simplifier's internal cache
   285          * Add a name usage to the simplifier's internal cache
   286          */
   286          */
   287         protected void addUsage(Symbol sym) {
   287         protected void addUsage(Symbol sym) {
   320                     name = buf.toString();
   320                     name = buf.toString();
   321                 }
   321                 }
   322             }
   322             }
   323             return name;
   323             return name;
   324         }
   324         }
   325     };
   325     }
   326     // </editor-fold>
   326     // </editor-fold>
   327 
   327 
   328     // <editor-fold defaultstate="collapsed" desc="rich printer">
   328     // <editor-fold defaultstate="collapsed" desc="rich printer">
   329     /**
   329     /**
   330      * Enhanced type/symbol printer that provides support for features like simple names
   330      * Enhanced type/symbol printer that provides support for features like simple names
   435                             locale) + ")";
   435                             locale) + ")";
   436                 }
   436                 }
   437                 return ms;
   437                 return ms;
   438             }
   438             }
   439         }
   439         }
   440     };
   440     }
   441     // </editor-fold>
   441     // </editor-fold>
   442 
   442 
   443     // <editor-fold defaultstate="collapsed" desc="type scanner">
   443     // <editor-fold defaultstate="collapsed" desc="type scanner">
   444     /**
   444     /**
   445      * Preprocess a given type looking for (i) additional info (where clauses) to be
   445      * Preprocess a given type looking for (i) additional info (where clauses) to be
   702             /** a list of additional info regarding a given type/symbol */
   702             /** a list of additional info regarding a given type/symbol */
   703             WHERE_CLAUSES,
   703             WHERE_CLAUSES,
   704             /** full class names simplification (where possible) */
   704             /** full class names simplification (where possible) */
   705             SIMPLE_NAMES,
   705             SIMPLE_NAMES,
   706             /** type-variable names disambiguation */
   706             /** type-variable names disambiguation */
   707             UNIQUE_TYPEVAR_NAMES;
   707             UNIQUE_TYPEVAR_NAMES
   708         }
   708         }
   709     }
   709     }
   710 }
   710 }