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

Side by Side Diff: lib/strong_mode.dart

Issue 1392383002: further refactoring: merge RestrictedRules into TypeRules (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebase Created 5 years, 2 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/compiler.dart ('k') | no next file » | 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 /// 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 10 show
11 AnalysisContext, 11 AnalysisContext,
12 AnalysisContextImpl, 12 AnalysisContextImpl,
13 AnalysisEngine, 13 AnalysisEngine,
14 AnalysisErrorInfo, 14 AnalysisErrorInfo,
15 AnalysisErrorInfoImpl; 15 AnalysisErrorInfoImpl;
16 import 'package:analyzer/src/generated/error.dart' 16 import 'package:analyzer/src/generated/error.dart'
17 show 17 show
18 AnalysisError, 18 AnalysisError,
19 AnalysisErrorListener, 19 AnalysisErrorListener,
20 CompileTimeErrorCode, 20 CompileTimeErrorCode,
21 ErrorCode, 21 ErrorCode,
22 ErrorSeverity, 22 ErrorSeverity,
23 HintCode, 23 HintCode,
24 StaticTypeWarningCode; 24 StaticTypeWarningCode;
25 import 'package:analyzer/src/generated/source.dart' show Source; 25 import 'package:analyzer/src/generated/source.dart' show Source;
26 import 'package:args/args.dart'; 26 import 'package:args/args.dart';
27 27
28 import 'src/analysis_context.dart' show enableDevCompilerInference; 28 import 'src/analysis_context.dart' show enableDevCompilerInference;
29 import 'src/checker/checker.dart' show CodeChecker; 29 import 'src/checker/checker.dart' show CodeChecker;
30 import 'src/checker/rules.dart' show RestrictedRules; 30 import 'src/checker/rules.dart' show TypeRules;
31 31
32 /// A type checker for Dart code that operates under stronger rules, and has 32 /// A type checker for Dart code that operates under stronger rules, and has
33 /// the ability to do local type inference in some situations. 33 /// the ability to do local type inference in some situations.
34 class StrongChecker { 34 class StrongChecker {
35 final AnalysisContext _context; 35 final AnalysisContext _context;
36 final CodeChecker _checker; 36 final CodeChecker _checker;
37 final _ErrorCollector _reporter; 37 final _ErrorCollector _reporter;
38 38
39 StrongChecker._(this._context, this._checker, this._reporter); 39 StrongChecker._(this._context, this._checker, this._reporter);
40 40
41 factory StrongChecker(AnalysisContext context, StrongModeOptions options) { 41 factory StrongChecker(AnalysisContext context, StrongModeOptions options) {
42 // TODO(vsm): Remove this once analyzer_cli is completely switched to the 42 // TODO(vsm): Remove this once analyzer_cli is completely switched to the
43 // task model. 43 // task model.
44 if (!AnalysisEngine 44 if (!AnalysisEngine
45 .instance.useTaskModel) enableDevCompilerInference(context, options); 45 .instance.useTaskModel) enableDevCompilerInference(context, options);
46 var rules = new RestrictedRules(context.typeProvider, options: options); 46 var rules = new TypeRules(context.typeProvider, options: options);
47 var reporter = new _ErrorCollector(options.hints); 47 var reporter = new _ErrorCollector(options.hints);
48 var checker = new CodeChecker(rules, reporter); 48 var checker = new CodeChecker(rules, reporter);
49 return new StrongChecker._(context, checker, reporter); 49 return new StrongChecker._(context, checker, reporter);
50 } 50 }
51 51
52 /// Computes and returns DDC errors for the [source]. 52 /// Computes and returns DDC errors for the [source].
53 AnalysisErrorInfo computeErrors(Source source) { 53 AnalysisErrorInfo computeErrors(Source source) {
54 var errors = new List<AnalysisError>(); 54 var errors = new List<AnalysisError>();
55 _reporter.errors = errors; 55 _reporter.errors = errors;
56 56
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 bool operator ==(Object other) { 160 bool operator ==(Object other) {
161 if (other is! StrongModeOptions) return false; 161 if (other is! StrongModeOptions) return false;
162 StrongModeOptions s = other; 162 StrongModeOptions s = other;
163 return inferTransitively == s.inferTransitively && 163 return inferTransitively == s.inferTransitively &&
164 onlyInferConstsAndFinalFields == s.onlyInferConstsAndFinalFields && 164 onlyInferConstsAndFinalFields == s.onlyInferConstsAndFinalFields &&
165 inferDownwards == s.inferDownwards && 165 inferDownwards == s.inferDownwards &&
166 relaxedCasts == s.relaxedCasts; 166 relaxedCasts == s.relaxedCasts;
167 } 167 }
168 } 168 }
OLDNEW
« no previous file with comments | « lib/src/compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698