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 /// Types needed to implement "strong" checking in the Dart analyzer. This is | 5 /// Types needed to implement "strong" checking in the Dart analyzer. This is |
6 /// intended to be used by `analyzer_cli` and `analysis_server` packages. | 6 /// intended to be used by `analyzer_cli` and `analysis_server` packages. |
7 library dev_compiler.strong_mode; | 7 library dev_compiler.strong_mode; |
8 | 8 |
9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
10 show AnalysisContextImpl, AnalysisErrorInfo, AnalysisErrorInfoImpl; | 10 show AnalysisContext, AnalysisContextImpl, AnalysisEngine, AnalysisErrorInfo
, AnalysisErrorInfoImpl; |
11 import 'package:analyzer/src/generated/error.dart' | 11 import 'package:analyzer/src/generated/error.dart' |
12 show | 12 show |
13 AnalysisError, | 13 AnalysisError, |
14 AnalysisErrorListener, | 14 AnalysisErrorListener, |
15 CompileTimeErrorCode, | 15 CompileTimeErrorCode, |
16 ErrorCode, | 16 ErrorCode, |
17 ErrorSeverity, | 17 ErrorSeverity, |
18 HintCode, | 18 HintCode, |
19 StaticTypeWarningCode; | 19 StaticTypeWarningCode; |
20 import 'package:analyzer/src/generated/source.dart' show Source; | 20 import 'package:analyzer/src/generated/source.dart' show Source; |
21 import 'package:args/args.dart'; | 21 import 'package:args/args.dart'; |
22 | 22 |
23 import 'src/analysis_context.dart' show enableDevCompilerInference; | 23 import 'src/analysis_context.dart' show enableDevCompilerInference; |
24 import 'src/checker/checker.dart' show CodeChecker; | 24 import 'src/checker/checker.dart' show CodeChecker; |
25 import 'src/checker/rules.dart' show RestrictedRules; | 25 import 'src/checker/rules.dart' show RestrictedRules; |
26 | 26 |
27 /// A type checker for Dart code that operates under stronger rules, and has | 27 /// A type checker for Dart code that operates under stronger rules, and has |
28 /// the ability to do local type inference in some situations. | 28 /// the ability to do local type inference in some situations. |
29 class StrongChecker { | 29 class StrongChecker { |
30 final AnalysisContextImpl _context; | 30 final AnalysisContext _context; |
31 final CodeChecker _checker; | 31 final CodeChecker _checker; |
32 final _ErrorCollector _reporter; | 32 final _ErrorCollector _reporter; |
33 | 33 |
34 StrongChecker._(this._context, this._checker, this._reporter); | 34 StrongChecker._(this._context, this._checker, this._reporter); |
35 | 35 |
36 factory StrongChecker( | 36 factory StrongChecker( |
37 AnalysisContextImpl context, StrongModeOptions options) { | 37 AnalysisContext context, StrongModeOptions options) { |
38 enableDevCompilerInference(context, options); | 38 if (!AnalysisEngine.instance.useTaskModel) enableDevCompilerInference(contex
t, options); |
39 var rules = new RestrictedRules(context.typeProvider, options: options); | 39 var rules = new RestrictedRules(context.typeProvider, options: options); |
40 var reporter = new _ErrorCollector(options.hints); | 40 var reporter = new _ErrorCollector(options.hints); |
41 var checker = new CodeChecker(rules, reporter, options); | 41 var checker = new CodeChecker(rules, reporter, options); |
42 return new StrongChecker._(context, checker, reporter); | 42 return new StrongChecker._(context, checker, reporter); |
43 } | 43 } |
44 | 44 |
45 /// Computes and returns DDC errors for the [source]. | 45 /// Computes and returns DDC errors for the [source]. |
46 AnalysisErrorInfo computeErrors(Source source) { | 46 AnalysisErrorInfo computeErrors(Source source) { |
47 var errors = new List<AnalysisError>(); | 47 var errors = new List<AnalysisError>(); |
48 _reporter.errors = errors; | 48 _reporter.errors = errors; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 List<String> _optionsToList(String option, | 184 List<String> _optionsToList(String option, |
185 {List<String> defaultValue: const <String>[]}) { | 185 {List<String> defaultValue: const <String>[]}) { |
186 if (option == null) { | 186 if (option == null) { |
187 return defaultValue; | 187 return defaultValue; |
188 } else if (option.isEmpty) { | 188 } else if (option.isEmpty) { |
189 return <String>[]; | 189 return <String>[]; |
190 } else { | 190 } else { |
191 return option.split(','); | 191 return option.split(','); |
192 } | 192 } |
193 } | 193 } |
OLD | NEW |