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

Unified Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 1305863011: Improve strong-mode implementation and fix several failing tests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months 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
Index: pkg/analyzer/lib/src/generated/engine.dart
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index 5eccbf7ee5b33c7932856815551ae5e221f02f47..80b2ad660c9136d9ce24d89d8fa77589af93eeff 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -8415,6 +8415,62 @@ class DefaultRetentionPolicy implements CacheRetentionPolicy {
}
/**
+ * An error listener that can be enabled or disabled while executing a function.
+ */
+class DisablableErrorListener implements AnalysisErrorListener {
scheglov 2015/09/08 15:36:22 Why don't we put it in error.dart ?
Brian Wilkerson 2015/09/08 17:10:33 Done
+ /**
+ * The listener to which errors will be reported if this listener is enabled.
+ */
+ final AnalysisErrorListener baseListener;
+
+ /**
+ * A flag indicating whether this listener is currently enabled.
+ */
+ bool enabled = true;
+
+ /**
+ * Initialize a newly created listener to report errors to the given
+ * [baseListener].
+ */
+ DisablableErrorListener(this.baseListener);
+
+ /**
+ * Disable the processing of errors while evaluating the given [function].
+ * Return the value returned by the function.
+ */
+ dynamic disableWhile(dynamic function()) {
+ bool wasEnabled = enabled;
+ try {
+ enabled = false;
+ return function();
+ } finally {
+ enabled = wasEnabled;
+ }
+ }
+
+ /**
+ * Disable the processing of errors while evaluating the given [function].
+ * Return the value returned by the function.
+ */
+ dynamic enableWhile(dynamic function()) {
+ bool wasEnabled = enabled;
+ try {
+ enabled = true;
+ return function();
+ } finally {
+ enabled = wasEnabled;
+ }
+ }
+
+ @override
+ void onError(AnalysisError error) {
+ if (enabled) {
+ baseListener.onError(error);
+ }
+ }
+}
+
+/**
* Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single
* Dart source.
*/
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | pkg/analyzer/lib/src/generated/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698