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

Side by Side Diff: lib/strong_mode.dart

Issue 1235503010: fixes #219, able to compile multiple entry points (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
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. 5 /// Types needed to implement "strong" checking in the Dart analyzer.
6 /// This is intended to be used by analyzer_cli and analysis_server packages. 6 /// This is 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 AnalysisContextImpl, 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/checker/checker.dart' show CodeChecker; 24 import 'src/checker/checker.dart' show CodeChecker;
24 import 'src/checker/resolver.dart' show LibraryResolverWithInference;
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 AnalysisContextImpl _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 AnalysisContextImpl context, StrongModeOptions options) {
38 // TODO(jmesserly): is there a cleaner way to plug this in? 38 enableDevCompilerInference(context, options);
39 if (context.libraryResolverFactory != null) {
40 throw new ArgumentError.value(context, 'context',
41 'Analysis context must not have libraryResolverFactory already set.');
42 }
43 context.libraryResolverFactory =
44 (c) => new LibraryResolverWithInference(c, options);
45
46 var rules = new RestrictedRules(context.typeProvider, options: options); 39 var rules = new RestrictedRules(context.typeProvider, options: options);
47 var reporter = new _ErrorCollector(options.hints); 40 var reporter = new _ErrorCollector(options.hints);
48 var checker = new CodeChecker(rules, reporter, options); 41 var checker = new CodeChecker(rules, reporter, options);
49 return new StrongChecker._(context, checker, reporter); 42 return new StrongChecker._(context, checker, reporter);
50 } 43 }
51 44
52 /// Computes and returns DDC errors for the [source]. 45 /// Computes and returns DDC errors for the [source].
53 AnalysisErrorInfo computeErrors(Source source) { 46 AnalysisErrorInfo computeErrors(Source source) {
54 var errors = new List<AnalysisError>(); 47 var errors = new List<AnalysisError>();
55 _reporter.errors = errors; 48 _reporter.errors = errors;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 List<String> _optionsToList(String option, 183 List<String> _optionsToList(String option,
191 {List<String> defaultValue: const <String>[]}) { 184 {List<String> defaultValue: const <String>[]}) {
192 if (option == null) { 185 if (option == null) {
193 return defaultValue; 186 return defaultValue;
194 } else if (option.isEmpty) { 187 } else if (option.isEmpty) {
195 return <String>[]; 188 return <String>[];
196 } else { 189 } else {
197 return option.split(','); 190 return option.split(',');
198 } 191 }
199 } 192 }
OLDNEW
« lib/src/summary.dart ('K') | « lib/src/testing.dart ('k') | test/all_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698