Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart

Issue 1513263002: Support optional package name arguments to --show-package-warnings (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/dart2js.dart ('k') | pkg/compiler/lib/src/library_loader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « pkg/compiler/lib/src/dart2js.dart ('k') | pkg/compiler/lib/src/library_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698