/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** A class for error logs. Reports errors and warnings, and
* keeps track of error numbers and positions.
*
* <p><b>This is NOT part of any supported API.
* 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.</b>
*/
/** The context key for the log. */
/** The context key for the output PrintWriter. */
//@Deprecated
//@Deprecated
//@Deprecated
*/
public final int MaxErrors;
public final int MaxWarnings;
/** Switch: prompt user on each error.
*/
public boolean promptOnError;
/** Switch: emit warning messages.
*/
public boolean emitWarnings;
/** Switch: suppress note messages.
*/
public boolean suppressNotes;
/** Print stack trace on errors?
*/
public boolean dumpOnError;
/** Print multiple errors for same source locations.
*/
public boolean multipleErrors;
/**
* Diagnostic listener, if provided through programmatic
* interface to javac (JSR 199).
*/
/**
* Formatter for diagnostics.
*/
/**
* Keys for expected diagnostics.
*/
/**
* JavacMessages object used for localization.
*/
/**
* Deferred diagnostics
*/
public boolean deferDiagnostics;
/** Construct a log with given I/O redirections.
*/
protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
this.warnWriter = warnWriter;
this.noticeWriter = noticeWriter;
this.diagListener = dl;
}
// where
try {
if (s != null) {
}
} catch (NumberFormatException e) {
// silently ignore ill-formed numbers
}
return defaultValue;
}
/** Default value for -Xmaxerrs.
*/
protected int getDefaultMaxErrors() {
return 100;
}
/** Default value for -Xmaxwarns.
*/
protected int getDefaultMaxWarnings() {
return 100;
}
/** The default writer for diagnostics
*/
return result;
}
/** Construct a log with default settings.
*/
}
/** Construct a log with all output redirected.
*/
}
/** Get the Log instance for this context. */
return instance;
}
/** The number of errors encountered so far.
*/
/** The number of warnings encountered so far.
*/
/** A set of all errors generated so far. This is used to avoid printing an
* error message more than once. For each error, a pair consisting of the
* source file name and source code position of the error is added to the set.
*/
public boolean hasDiagnosticListener() {
return diagListener != null;
}
}
/** Return current sourcefile.
*/
}
/** Get the current diagnostic formatter.
*/
return diagFormatter;
}
/** Set the current diagnostic formatter.
*/
this.diagFormatter = diagFormatter;
}
/** Flush the logs
*/
public void flush() {
warnWriter.flush();
}
/** Returns true if an error needs to be reported for a given
* source name and pos.
*/
return true;
if (shouldReport)
return shouldReport;
}
/** Prompt user after an error.
*/
public void prompt() {
if (promptOnError) {
char ch;
try {
while (true) {
case 'a': case 'A':
return;
case 'r': case 'R':
return;
case 'x': case 'X':
throw new AssertionError("user abort");
default:
}
}
} catch (IOException e) {}
}
}
/** Print the faulty source code line and point to the error.
* @param pos Buffer index of the error position, must be on current line
*/
return;
}
}
/** Print the text of a message, translating newlines appropriately
* for the platform.
*/
int nl;
}
}
/** Print the text of a message to the errWriter stream,
* translating newlines appropriately for the platform.
*/
}
/** Print the text of a message to the noticeWriter stream,
* translating newlines appropriately for the platform.
*/
}
/**
* Print the localized text of a "verbose" message to the
* noticeWriter stream.
*/
}
}
/** Report a warning that cannot be suppressed.
* @param pos The source position at which to report the warning.
* @param key The key for the localized warning message.
* @param args Fields of the warning message.
*/
nwarnings++;
}
/** Report all deferred diagnostics, and clear the deferDiagnostics flag. */
public void reportDeferredDiagnostics() {
}
/** Report selected deferred diagnostics, and clear the deferDiagnostics flag. */
deferDiagnostics = false;
JCDiagnostic d;
report(d);
}
}
/**
* Common diagnostic handling.
* The diagnostic is counted, and depending on the options and how many diagnostics have been
* reported so far, the diagnostic may be handed off to writeDiagnostic.
*/
if (deferDiagnostics) {
return;
}
if (expectDiagKeys != null)
switch (diagnostic.getType()) {
case FRAGMENT:
throw new IllegalArgumentException();
case NOTE:
// Print out notes only when we are permitted to report warnings
// Notes are only generated at the end of a compilation, so should be small
// in number.
}
break;
case WARNING:
if (nwarnings < MaxWarnings) {
nwarnings++;
}
}
break;
case ERROR:
nerrors++;
}
break;
}
}
/**
* Write out a diagnostic.
*/
if (diagListener != null) {
return;
}
if (promptOnError) {
case ERROR:
case WARNING:
prompt();
}
}
if (dumpOnError)
}
switch (dt) {
case FRAGMENT:
throw new IllegalArgumentException();
case NOTE:
return noticeWriter;
case WARNING:
return warnWriter;
case ERROR:
return errWriter;
default:
throw new Error();
}
}
/** Find a localized string in the resource bundle.
* Because this method is static, it ignores the locale.
* Use localize(key, args) when possible.
* @param key The key for the localized string.
* @param args Fields to substitute into the string.
*/
}
/** Find a localized string in the resource bundle.
* @param key The key for the localized string.
* @param args Fields to substitute into the string.
*/
}
/***************************************************************************
* raw error messages without internationalization; used for experimentation
* and quick prototyping
***************************************************************************/
/** print an error or warning message:
*/
} else {
}
}
/** report an error:
*/
prompt();
nerrors++;
}
}
/** report a warning:
*/
}
prompt();
nwarnings++;
}
}
}