| OLD | NEW |
| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 | 325 |
| 326 /// Checks the body of functions and properties. | 326 /// Checks the body of functions and properties. |
| 327 class CodeChecker extends RecursiveAstVisitor { | 327 class CodeChecker extends RecursiveAstVisitor { |
| 328 final TypeRules rules; | 328 final TypeRules rules; |
| 329 final AnalysisErrorListener reporter; | 329 final AnalysisErrorListener reporter; |
| 330 final _OverrideChecker _overrideChecker; | 330 final _OverrideChecker _overrideChecker; |
| 331 bool _failure = false; | 331 bool _failure = false; |
| 332 bool get failure => _failure || _overrideChecker._failure; | 332 bool get failure => _failure || _overrideChecker._failure; |
| 333 | 333 |
| 334 void reset() { |
| 335 _failure = false; |
| 336 _overrideChecker._failure = false; |
| 337 } |
| 338 |
| 334 CodeChecker(TypeRules rules, AnalysisErrorListener reporter, | 339 CodeChecker(TypeRules rules, AnalysisErrorListener reporter, |
| 335 StrongModeOptions options) | 340 StrongModeOptions options) |
| 336 : rules = rules, | 341 : rules = rules, |
| 337 reporter = reporter, | 342 reporter = reporter, |
| 338 _overrideChecker = new _OverrideChecker(rules, reporter, options); | 343 _overrideChecker = new _OverrideChecker(rules, reporter, options); |
| 339 | 344 |
| 340 @override | 345 @override |
| 341 void visitCompilationUnit(CompilationUnit unit) { | 346 void visitCompilationUnit(CompilationUnit unit) { |
| 342 void report(Expression expr) { | 347 void report(Expression expr) { |
| 343 reporter.onError(new MissingTypeError(expr).toAnalysisError()); | 348 reporter.onError(new MissingTypeError(expr).toAnalysisError()); |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 if (info is CoercionInfo) { | 961 if (info is CoercionInfo) { |
| 957 // TODO(jmesserly): if we're run again on the same AST, we'll produce the | 962 // TODO(jmesserly): if we're run again on the same AST, we'll produce the |
| 958 // same annotations. This should be harmless. This might go away once | 963 // same annotations. This should be harmless. This might go away once |
| 959 // CodeChecker is integrated better with analyzer, as it will know that | 964 // CodeChecker is integrated better with analyzer, as it will know that |
| 960 // checking has already been performed. | 965 // checking has already been performed. |
| 961 // assert(CoercionInfo.get(info.node) == null); | 966 // assert(CoercionInfo.get(info.node) == null); |
| 962 CoercionInfo.set(info.node, info); | 967 CoercionInfo.set(info.node, info); |
| 963 } | 968 } |
| 964 } | 969 } |
| 965 } | 970 } |
| OLD | NEW |