--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Fri Jun 20 11:25:03 2008 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Wed Jun 25 14:24:53 2008 -0700
@@ -34,7 +34,6 @@
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
-import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -86,10 +85,6 @@
*/
public boolean emitWarnings;
- /** Enforce mandatory warnings.
- */
- private boolean enforceMandatoryWarnings;
-
/** Print stack trace on errors?
*/
public boolean dumpOnError;
@@ -138,9 +133,6 @@
DiagnosticListener<? super JavaFileObject> diagListener =
context.get(DiagnosticListener.class);
this.diagListener = diagListener;
-
- Source source = Source.instance(context);
- this.enforceMandatoryWarnings = source.enforceMandatoryWarnings();
}
// where
private int getIntOption(Options options, String optionName, int defaultValue) {
@@ -473,10 +465,7 @@
* @param args Fields of the warning message.
*/
public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) {
- if (enforceMandatoryWarnings)
- report(diags.mandatoryWarning(source, pos, key, args));
- else
- report(diags.warning(source, pos, key, args));
+ report(diags.mandatoryWarning(source, pos, key, args));
}
/** Report a warning that cannot be suppressed.
@@ -514,34 +503,43 @@
}
/** Provide a non-fatal notification, unless suppressed by the -nowarn option.
+ * @param file The file to which the note applies.
+ * @param key The key for the localized notification message.
+ * @param args Fields of the notification message.
+ */
+ public void note(JavaFileObject file, String key, Object ... args) {
+ report(diags.note(wrap(file), null, key, args));
+ }
+
+ /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
* @param key The key for the localized notification message.
* @param args Fields of the notification message.
*/
public void mandatoryNote(final JavaFileObject file, String key, Object ... args) {
- JCDiagnostic.DiagnosticSource wrapper = null;
- if (file != null) {
- wrapper = new JCDiagnostic.DiagnosticSource() {
- public JavaFileObject getFile() {
- return file;
- }
- public CharSequence getName() {
- return JavacFileManager.getJavacBaseFileName(getFile());
- }
- public int getLineNumber(int pos) {
- return Log.this.getLineNumber(pos);
- }
- public int getColumnNumber(int pos) {
- return Log.this.getColumnNumber(pos);
- }
- public Map<JCTree, Integer> getEndPosTable() {
- return (endPosTables == null ? null : endPosTables.get(file));
- }
- };
+ report(diags.mandatoryNote(wrap(file), key, args));
+ }
+
+ private JCDiagnostic.DiagnosticSource wrap(final JavaFileObject file) {
+ if (file == null) {
+ return null;
}
- if (enforceMandatoryWarnings)
- report(diags.mandatoryNote(wrapper, key, args));
- else
- report(diags.note(wrapper, null, key, args));
+ return new JCDiagnostic.DiagnosticSource() {
+ public JavaFileObject getFile() {
+ return file;
+ }
+ public CharSequence getName() {
+ return JavacFileManager.getJavacBaseFileName(getFile());
+ }
+ public int getLineNumber(int pos) {
+ return Log.this.getLineNumber(pos);
+ }
+ public int getColumnNumber(int pos) {
+ return Log.this.getColumnNumber(pos);
+ }
+ public Map<JCTree, Integer> getEndPosTable() {
+ return (endPosTables == null ? null : endPosTables.get(file));
+ }
+ };
}
private DiagnosticPosition wrap(int pos) {