|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.tools.javac.util.AbstractLog
com.sun.tools.javac.util.Log
public class Log
A class for error logs. Reports errors and warnings, and keeps track of error numbers and positions.
This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Field Summary | |
---|---|
private DiagnosticFormatter<JCDiagnostic> |
diagFormatter
Formatter for diagnostics |
protected DiagnosticListener<? super JavaFileObject> |
diagListener
Diagnostic listener, if provided through programmatic interface to javac (JSR 199). |
boolean |
dumpOnError
Print stack trace on errors? |
boolean |
emitWarnings
Switch: emit warning messages. |
java.io.PrintWriter |
errWriter
|
java.util.Set<java.lang.String> |
expectDiagKeys
Keys for expected diagnostics |
static Context.Key<Log> |
logKey
The context key for the log. |
int |
MaxErrors
The maximum number of errors/warnings that are reported. |
int |
MaxWarnings
|
private JavacMessages |
messages
JavacMessages object used for localization |
boolean |
multipleErrors
Print multiple errors for same source locations. |
int |
nerrors
The number of errors encountered so far. |
java.io.PrintWriter |
noticeWriter
|
int |
nwarnings
The number of warnings encountered so far. |
static Context.Key<java.io.PrintWriter> |
outKey
The context key for the output PrintWriter. |
boolean |
promptOnError
Switch: prompt user on each error. |
private java.util.Set<Pair<JavaFileObject,java.lang.Integer>> |
recorded
A set of all errors generated so far. |
java.io.PrintWriter |
warnWriter
|
Fields inherited from class com.sun.tools.javac.util.AbstractLog |
---|
diags, source, sourceMap |
Constructor Summary | |
---|---|
protected |
Log(Context context)
Construct a log with default settings. |
protected |
Log(Context context,
java.io.PrintWriter defaultWriter)
Construct a log with all output redirected. |
protected |
Log(Context context,
java.io.PrintWriter errWriter,
java.io.PrintWriter warnWriter,
java.io.PrintWriter noticeWriter)
Deprecated. |
Method Summary | |
---|---|
JavaFileObject |
currentSourceFile()
Return current sourcefile. |
(package private) static java.io.PrintWriter |
defaultWriter(Context context)
The default writer for diagnostics |
protected void |
directError(java.lang.String key,
java.lang.Object... args)
|
void |
flush()
Flush the logs |
static java.lang.String |
format(java.lang.String fmt,
java.lang.Object... args)
|
private int |
getIntOption(Options options,
java.lang.String optionName,
int defaultValue)
|
static java.lang.String |
getLocalizedString(java.lang.String key,
java.lang.Object... args)
Find a localized string in the resource bundle. |
protected java.io.PrintWriter |
getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt)
Deprecated. |
boolean |
hasDiagnosticListener()
|
static Log |
instance(Context context)
Get the Log instance for this context. |
private void |
printErrLine(int pos,
java.io.PrintWriter writer)
Print the faulty source code line and point to the error. |
static void |
printLines(java.io.PrintWriter writer,
java.lang.String msg)
Print the text of a message, translating newlines appropriately for the platform. |
private void |
printRawError(int pos,
java.lang.String msg)
print an error or warning message: |
void |
prompt()
Prompt user after an error. |
void |
rawError(int pos,
java.lang.String msg)
report an error: |
void |
rawWarning(int pos,
java.lang.String msg)
report a warning: |
void |
report(JCDiagnostic diagnostic)
Common diagnostic handling. |
void |
setEndPosTable(JavaFileObject name,
java.util.Map<JCTree,java.lang.Integer> table)
|
protected boolean |
shouldReport(JavaFileObject file,
int pos)
Returns true if an error needs to be reported for a given source name and pos. |
void |
strictWarning(JCDiagnostic.DiagnosticPosition pos,
java.lang.String key,
java.lang.Object... args)
Report a warning that cannot be suppressed. |
protected void |
writeDiagnostic(JCDiagnostic diag)
Write out a diagnostic. |
Methods inherited from class com.sun.tools.javac.util.AbstractLog |
---|
currentSource, error, error, error, getSource, mandatoryNote, mandatoryWarning, note, note, note, note, useSource, warning, warning, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Context.Key<Log> logKey
public static final Context.Key<java.io.PrintWriter> outKey
public final java.io.PrintWriter errWriter
public final java.io.PrintWriter warnWriter
public final java.io.PrintWriter noticeWriter
public final int MaxErrors
public final int MaxWarnings
public boolean promptOnError
public boolean emitWarnings
public boolean dumpOnError
public boolean multipleErrors
protected DiagnosticListener<? super JavaFileObject> diagListener
private DiagnosticFormatter<JCDiagnostic> diagFormatter
public java.util.Set<java.lang.String> expectDiagKeys
private JavacMessages messages
public int nerrors
public int nwarnings
private java.util.Set<Pair<JavaFileObject,java.lang.Integer>> recorded
Constructor Detail |
---|
@Deprecated protected Log(Context context, java.io.PrintWriter errWriter, java.io.PrintWriter warnWriter, java.io.PrintWriter noticeWriter)
protected Log(Context context)
protected Log(Context context, java.io.PrintWriter defaultWriter)
Method Detail |
---|
private int getIntOption(Options options, java.lang.String optionName, int defaultValue)
static final java.io.PrintWriter defaultWriter(Context context)
public static Log instance(Context context)
public boolean hasDiagnosticListener()
public void setEndPosTable(JavaFileObject name, java.util.Map<JCTree,java.lang.Integer> table)
public JavaFileObject currentSourceFile()
public void flush()
protected boolean shouldReport(JavaFileObject file, int pos)
public void prompt()
private void printErrLine(int pos, java.io.PrintWriter writer)
pos
- Buffer index of the error position, must be on current linepublic static void printLines(java.io.PrintWriter writer, java.lang.String msg)
protected void directError(java.lang.String key, java.lang.Object... args)
directError
in class AbstractLog
public void strictWarning(JCDiagnostic.DiagnosticPosition pos, java.lang.String key, java.lang.Object... args)
pos
- The source position at which to report the warning.key
- The key for the localized warning message.args
- Fields of the warning message.public void report(JCDiagnostic diagnostic)
report
in class AbstractLog
protected void writeDiagnostic(JCDiagnostic diag)
@Deprecated protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt)
public static java.lang.String getLocalizedString(java.lang.String key, java.lang.Object... args)
key
- The key for the localized string.args
- Fields to substitute into the string.private void printRawError(int pos, java.lang.String msg)
public void rawError(int pos, java.lang.String msg)
public void rawWarning(int pos, java.lang.String msg)
public static java.lang.String format(java.lang.String fmt, java.lang.Object... args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |