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

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

Issue 1174643003: expose strong checker API, for use by analyzer_cli (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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/src/analysis_context.dart ('k') | lib/src/checker/resolver.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;
11 import 'package:logging/logging.dart' as logger; 11 import 'package:logging/logging.dart' as logger;
12 12
13 import 'package:dev_compiler/src/info.dart'; 13 import 'package:dev_compiler/src/info.dart';
14 import 'package:dev_compiler/src/options.dart';
15 import 'package:dev_compiler/src/report.dart' show CheckerReporter; 14 import 'package:dev_compiler/src/report.dart' show CheckerReporter;
16 import 'package:dev_compiler/src/utils.dart' show getMemberType; 15 import 'package:dev_compiler/src/utils.dart' show getMemberType;
16 import 'package:dev_compiler/strong_mode.dart' show StrongModeOptions;
17 import 'rules.dart'; 17 import 'rules.dart';
18 18
19 /// Checks for overriding declarations of fields and methods. This is used to 19 /// Checks for overriding declarations of fields and methods. This is used to
20 /// check overrides between classes and superclasses, interfaces, and mixin 20 /// check overrides between classes and superclasses, interfaces, and mixin
21 /// applications. 21 /// applications.
22 class _OverrideChecker { 22 class _OverrideChecker {
23 bool _failure = false; 23 bool _failure = false;
24 final TypeRules _rules; 24 final TypeRules _rules;
25 final CheckerReporter _reporter; 25 final CheckerReporter _reporter;
26 final bool _inferFromOverrides; 26 final bool _inferFromOverrides;
27 _OverrideChecker(this._rules, this._reporter, CompilerOptions options) 27 _OverrideChecker(this._rules, this._reporter, StrongModeOptions options)
28 : _inferFromOverrides = options.inferFromOverrides; 28 : _inferFromOverrides = options.inferFromOverrides;
29 29
30 void check(ClassDeclaration node) { 30 void check(ClassDeclaration node) {
31 if (node.element.type.isObject) return; 31 if (node.element.type.isObject) return;
32 _checkSuperOverrides(node); 32 _checkSuperOverrides(node);
33 _checkMixinApplicationOverrides(node); 33 _checkMixinApplicationOverrides(node);
34 _checkAllInterfaceOverrides(node); 34 _checkAllInterfaceOverrides(node);
35 } 35 }
36 36
37 /// Check overrides from mixin applications themselves. For example, in: 37 /// Check overrides from mixin applications themselves. For example, in:
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 /// Checks the body of functions and properties. 335 /// Checks the body of functions and properties.
336 class CodeChecker extends RecursiveAstVisitor { 336 class CodeChecker extends RecursiveAstVisitor {
337 final TypeRules _rules; 337 final TypeRules _rules;
338 final CheckerReporter _reporter; 338 final CheckerReporter _reporter;
339 final _OverrideChecker _overrideChecker; 339 final _OverrideChecker _overrideChecker;
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, StrongModeOptions 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 350 @override
351 void visitCompilationUnit(CompilationUnit unit) { 351 void visitCompilationUnit(CompilationUnit unit) {
352 void report(Expression expr) { 352 void report(Expression expr) {
353 _reporter.log(new MissingTypeError(expr)); 353 _reporter.log(new MissingTypeError(expr));
354 } 354 }
355 var callback = _rules.reportMissingType; 355 var callback = _rules.reportMissingType;
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 void _recordMessage(StaticInfo info) { 948 void _recordMessage(StaticInfo info) {
949 if (info == null) return; 949 if (info == null) return;
950 if (info.level >= logger.Level.SEVERE) _failure = true; 950 if (info.level >= logger.Level.SEVERE) _failure = true;
951 _reporter.log(info); 951 _reporter.log(info);
952 if (info is CoercionInfo) { 952 if (info is CoercionInfo) {
953 assert(CoercionInfo.get(info.node) == null); 953 assert(CoercionInfo.get(info.node) == null);
954 CoercionInfo.set(info.node, info); 954 CoercionInfo.set(info.node, info);
955 } 955 }
956 } 956 }
957 } 957 }
OLDNEW
« no previous file with comments | « lib/src/analysis_context.dart ('k') | lib/src/checker/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698