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

Side by Side Diff: lib/src/checker/checker.dart

Issue 1067553004: Factor out reporting from rules (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Change set/get pair to field 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 unified diff | Download patch
« no previous file with comments | « lib/devc.dart ('k') | lib/src/checker/rules.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dev_compiler.src.checker.checker; 5 library dev_compiler.src.checker.checker;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; 10 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 bool _constantContext = false; 340 bool _constantContext = false;
341 bool _failure = false; 341 bool _failure = false;
342 bool get failure => _failure || _overrideChecker._failure; 342 bool get failure => _failure || _overrideChecker._failure;
343 343
344 CodeChecker( 344 CodeChecker(
345 TypeRules rules, CheckerReporter reporter, CompilerOptions options) 345 TypeRules rules, CheckerReporter reporter, CompilerOptions options)
346 : _rules = rules, 346 : _rules = rules,
347 _reporter = reporter, 347 _reporter = reporter,
348 _overrideChecker = new _OverrideChecker(rules, reporter, options); 348 _overrideChecker = new _OverrideChecker(rules, reporter, options);
349 349
350 @override
351 visitCompilationUnit(CompilationUnit unit) {
352 void report(Expression expr) {
353 _reporter.log(new MissingTypeError(expr));
354 }
355 var callback = _rules.reportMissingType;
356 _rules.reportMissingType = report;
357 unit.visitChildren(this);
358 _rules.reportMissingType = callback;
359 }
360
350 _visitMaybeConst(AstNode n, visitNode(AstNode n)) { 361 _visitMaybeConst(AstNode n, visitNode(AstNode n)) {
351 var o = _constantContext; 362 var o = _constantContext;
352 if (!o) { 363 if (!o) {
353 if (n is VariableDeclarationList) { 364 if (n is VariableDeclarationList) {
354 _constantContext = o || n.isConst; 365 _constantContext = o || n.isConst;
355 } else if (n is VariableDeclaration) { 366 } else if (n is VariableDeclaration) {
356 _constantContext = o || n.isConst; 367 _constantContext = o || n.isConst;
357 } else if (n is FormalParameter) { 368 } else if (n is FormalParameter) {
358 _constantContext = o || n.isConst; 369 _constantContext = o || n.isConst;
359 } else if (n is InstanceCreationExpression) { 370 } else if (n is InstanceCreationExpression) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 void _recordDynamicInvoke(AstNode node) { 803 void _recordDynamicInvoke(AstNode node) {
793 _reporter.log(new DynamicInvoke(_rules, node)); 804 _reporter.log(new DynamicInvoke(_rules, node));
794 } 805 }
795 806
796 void _recordMessage(StaticInfo info) { 807 void _recordMessage(StaticInfo info) {
797 if (info == null) return; 808 if (info == null) return;
798 if (info.level >= logger.Level.SEVERE) _failure = true; 809 if (info.level >= logger.Level.SEVERE) _failure = true;
799 _reporter.log(info); 810 _reporter.log(info);
800 } 811 }
801 } 812 }
OLDNEW
« no previous file with comments | « lib/devc.dart ('k') | lib/src/checker/rules.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698