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

Unified Diff: lib/src/checker/rules.dart

Issue 1067553004: Factor out reporting from rules (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/codegen/code_generator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/checker/rules.dart
diff --git a/lib/src/checker/rules.dart b/lib/src/checker/rules.dart
index ef09d3b871cb37a522590947b52d22e2cb31f900..941791732c38d95402edd148e8a0aa59e19b87f5 100644
--- a/lib/src/checker/rules.dart
+++ b/lib/src/checker/rules.dart
@@ -10,7 +10,6 @@ import 'package:analyzer/src/generated/resolver.dart';
import 'package:dev_compiler/src/info.dart';
import 'package:dev_compiler/src/options.dart';
-import 'package:dev_compiler/src/report.dart' show CheckerReporter;
abstract class TypeRules {
final TypeProvider provider;
@@ -18,6 +17,9 @@ abstract class TypeRules {
TypeRules(TypeProvider this.provider);
+ set reportMissingType(MissingTypeReporter callback);
+ MissingTypeReporter get reportMissingType;
+
bool isSubTypeOf(DartType t1, DartType t2);
bool isAssignable(DartType t1, DartType t2);
@@ -51,6 +53,9 @@ abstract class TypeRules {
class DartRules extends TypeRules {
DartRules(TypeProvider provider) : super(provider);
+ set reportMissingType(MissingTypeReporter callback) {}
+ MissingTypeReporter get reportMissingType => null;
+
bool isSubTypeOf(DartType t1, DartType t2) {
return t1.isSubtypeOf(t2);
}
@@ -79,12 +84,17 @@ class DartRules extends TypeRules {
bool isDynamicCall(Expression call) => true;
}
+typedef void MissingTypeReporter(Expression expr);
+
class RestrictedRules extends TypeRules {
- final CheckerReporter _reporter;
+ MissingTypeReporter _reporter;
final RulesOptions options;
final List<DartType> _nonnullableTypes;
DownwardsInference inferrer;
+ set reportMissingType(MissingTypeReporter callback) => _reporter = callback;
Jennifer Messerly 2015/04/07 14:52:22 this should just be a field? MissingTypeReporter
Leaf 2015/04/07 16:56:25 Done.
+ MissingTypeReporter get reportMissingType => _reporter;
+
DartType _typeFromName(String name) {
switch (name) {
case 'int':
@@ -102,7 +112,7 @@ class RestrictedRules extends TypeRules {
}
}
- RestrictedRules(TypeProvider provider, this._reporter, {this.options})
+ RestrictedRules(TypeProvider provider, {this.options})
: _nonnullableTypes = <DartType>[],
super(provider) {
var types = options.nonnullableTypes;
@@ -113,7 +123,7 @@ class RestrictedRules extends TypeRules {
DartType getStaticType(Expression expr) {
var type = expr.staticType;
if (type != null) return type;
- _reporter.log(new MissingTypeError(expr));
+ if (_reporter != null) _reporter(expr);
return provider.dynamicType;
}
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/codegen/code_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698