< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java

Print this page




  44 import com.sun.tools.javac.code.Lint.LintCategory;
  45 import com.sun.tools.javac.code.Printer;
  46 import com.sun.tools.javac.code.Source;
  47 import com.sun.tools.javac.code.Symbol;
  48 import com.sun.tools.javac.code.Type;
  49 import com.sun.tools.javac.code.Type.CapturedType;
  50 import com.sun.tools.javac.file.PathFileObject;
  51 import com.sun.tools.javac.jvm.Profile;
  52 import com.sun.tools.javac.jvm.Target;
  53 import com.sun.tools.javac.main.Option;
  54 import com.sun.tools.javac.tree.JCTree.*;
  55 import com.sun.tools.javac.tree.Pretty;
  56 
  57 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
  58 
  59 /**
  60  * This abstract class provides a basic implementation of the functionalities that should be provided
  61  * by any formatter used by javac. Among the main features provided by AbstractDiagnosticFormatter are:
  62  *
  63  * <ul>
  64  *  <li> Provides a standard implementation of the visitor-like methods defined in the interface DiagnisticFormatter.
  65  *  Those implementations are specifically targeting JCDiagnostic objects.
  66  *  <li> Provides basic support for i18n and a method for executing all locale-dependent conversions
  67  *  <li> Provides the formatting logic for rendering the arguments of a JCDiagnostic object.
  68  * </ul>
  69  *
  70  * <p><b>This is NOT part of any supported API.
  71  * If you write code that depends on this, you do so at your own risk.
  72  * This code and its internal interfaces are subject to change or
  73  * deletion without notice.</b>
  74  */
  75 public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter<JCDiagnostic> {
  76 
  77     /**
  78      * JavacMessages object used by this formatter for i18n.
  79      */
  80     protected JavacMessages messages;
  81 
  82     /**
  83      * Configuration object used by this formatter
  84      */
  85     private SimpleConfiguration config;
  86 
  87     /**
  88      * Current depth level of the disgnostic being formatted
  89      * (!= 0 for subdiagnostics)
  90      */
  91     protected int depth = 0;
  92 
  93     /**
  94      * All captured types that have been encountered during diagnostic formatting.
  95      * This info is used by the FormatterPrinter in order to print friendly unique
  96      * ids for captured types
  97      */
  98     private List<Type> allCaptured = List.nil();
  99 
 100     /**
 101      * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object.
 102      * @param messages
 103      */
 104     protected AbstractDiagnosticFormatter(JavacMessages messages, SimpleConfiguration config) {
 105         this.messages = messages;
 106         this.config = config;
 107     }
 108 




  44 import com.sun.tools.javac.code.Lint.LintCategory;
  45 import com.sun.tools.javac.code.Printer;
  46 import com.sun.tools.javac.code.Source;
  47 import com.sun.tools.javac.code.Symbol;
  48 import com.sun.tools.javac.code.Type;
  49 import com.sun.tools.javac.code.Type.CapturedType;
  50 import com.sun.tools.javac.file.PathFileObject;
  51 import com.sun.tools.javac.jvm.Profile;
  52 import com.sun.tools.javac.jvm.Target;
  53 import com.sun.tools.javac.main.Option;
  54 import com.sun.tools.javac.tree.JCTree.*;
  55 import com.sun.tools.javac.tree.Pretty;
  56 
  57 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
  58 
  59 /**
  60  * This abstract class provides a basic implementation of the functionalities that should be provided
  61  * by any formatter used by javac. Among the main features provided by AbstractDiagnosticFormatter are:
  62  *
  63  * <ul>
  64  *  <li> Provides a standard implementation of the visitor-like methods defined in the interface DiagnosticFormatter.
  65  *  Those implementations are specifically targeting JCDiagnostic objects.
  66  *  <li> Provides basic support for i18n and a method for executing all locale-dependent conversions
  67  *  <li> Provides the formatting logic for rendering the arguments of a JCDiagnostic object.
  68  * </ul>
  69  *
  70  * <p><b>This is NOT part of any supported API.
  71  * If you write code that depends on this, you do so at your own risk.
  72  * This code and its internal interfaces are subject to change or
  73  * deletion without notice.</b>
  74  */
  75 public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter<JCDiagnostic> {
  76 
  77     /**
  78      * JavacMessages object used by this formatter for i18n.
  79      */
  80     protected JavacMessages messages;
  81 
  82     /**
  83      * Configuration object used by this formatter
  84      */
  85     private SimpleConfiguration config;
  86 
  87     /**
  88      * Current depth level of the diagnostic being formatted
  89      * (!= 0 for subdiagnostics)
  90      */
  91     protected int depth = 0;
  92 
  93     /**
  94      * All captured types that have been encountered during diagnostic formatting.
  95      * This info is used by the FormatterPrinter in order to print friendly unique
  96      * ids for captured types
  97      */
  98     private List<Type> allCaptured = List.nil();
  99 
 100     /**
 101      * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object.
 102      * @param messages
 103      */
 104     protected AbstractDiagnosticFormatter(JavacMessages messages, SimpleConfiguration config) {
 105         this.messages = messages;
 106         this.config = config;
 107     }
 108 


< prev index next >