langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java
changeset 3145 5300990c95bd
parent 2984 e15ff3a34054
child 3373 d62556aed18c
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jun 24 10:50:54 2009 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jun 24 10:51:13 2009 +0100
@@ -68,7 +68,10 @@
     final JavacMessages messages;
 
     /* name simplifier used by this formatter */
-    ClassNameSimplifier nameSimplifier;
+    protected ClassNameSimplifier nameSimplifier;
+
+    /* type/symbol printer used by this formatter */
+    private RichPrinter printer;
 
     /* map for keeping track of a where clause associated to a given type */
     Map<WhereClauseKind, Map<Type, JCDiagnostic>> whereClauses;
@@ -83,7 +86,7 @@
 
     protected RichDiagnosticFormatter(Context context) {
         super((AbstractDiagnosticFormatter)Log.instance(context).getDiagnosticFormatter());
-        this.formatter.setPrinter(printer);
+        setRichPrinter(new RichPrinter());
         this.syms = Symtab.instance(context);
         this.diags = JCDiagnostic.Factory.instance(context);
         this.types = Types.instance(context);
@@ -117,6 +120,23 @@
     }
 
     /**
+     * Sets the type/symbol printer used by this formatter.
+     * @param printer the rich printer to be set
+     */
+    protected void setRichPrinter(RichPrinter printer) {
+        this.printer = printer;
+        formatter.setPrinter(printer);
+    }
+
+    /**
+     * Gets the type/symbol printer used by this formatter.
+     * @return type/symbol rich printer
+     */
+    protected RichPrinter getRichPrinter() {
+        return printer;
+    }
+
+    /**
      * Preprocess a given diagnostic by looking both into its arguments and into
      * its subdiagnostics (if any). This preprocessing is responsible for
      * generating info corresponding to features like where clauses, name
@@ -217,7 +237,7 @@
      * name belong to different packages - in this case the formatter reverts
      * to fullnames as compact names might lead to a confusing diagnostic.
      */
-    class ClassNameSimplifier {
+    protected class ClassNameSimplifier {
 
         /* table for keeping track of all short name usages */
         Map<Name, List<Symbol>> nameClashes = new HashMap<Name, List<Symbol>>();
@@ -272,7 +292,7 @@
      * discovered during type/symbol preprocessing. This printer is set on the delegate
      * formatter so that rich type/symbol info can be properly rendered.
      */
-    protected Printer printer = new Printer() {
+    protected class RichPrinter extends Printer {
 
         @Override
         public String localize(Locale locale, String key, Object... args) {