Index: pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart |
diff --git a/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart b/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart |
index e4bd449879dcf2c9e8dd53742a69d5b56e3a435c..6a156ae42566f1f634b35ababa5782ab5350c026 100644 |
--- a/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart |
+++ b/pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart |
@@ -16,8 +16,10 @@ class DiagnosticOptions { |
/// Emit terse diagnostics without howToFix. |
final bool terseDiagnostics; |
- /// If `true`, warnings and hints not from user code are reported. |
- final bool showPackageWarnings; |
+ /// List of packages for which warnings and hints are reported. If `null`, |
+ /// no package warnings or hints are reported. If empty, all warnings and |
+ /// hints are reported. |
+ final List<String> _shownPackageWarnings; |
/// If `true`, warnings are not reported. |
final bool suppressWarnings; |
@@ -33,7 +35,29 @@ class DiagnosticOptions { |
this.fatalWarnings: false, |
this.suppressHints: false, |
this.terseDiagnostics: false, |
- this.showPackageWarnings: false}); |
+ List<String> shownPackageWarnings: null}) |
+ : _shownPackageWarnings = shownPackageWarnings; |
+ |
+ |
+ /// Returns `true` if warnings and hints are shown for all packages. |
+ bool get showAllPackageWarnings { |
+ return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty; |
+ } |
+ |
+ /// Returns `true` if warnings and hints are hidden for all packages. |
+ bool get hidePackageWarnings => _shownPackageWarnings == null; |
+ |
+ /// Returns `true` if warnings should be should for [uri]. |
+ bool showPackageWarningsFor(Uri uri) { |
+ if (showAllPackageWarnings) { |
+ return true; |
+ } |
+ if (_shownPackageWarnings != null) { |
+ return uri.scheme == 'package' && |
+ _shownPackageWarnings.contains(uri.pathSegments.first); |
+ } |
+ return false; |
+ } |
} |
// TODO(johnniwinther): Rename and cleanup this interface. Add severity enum. |