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.analysis_context; | 5 library dev_compiler.src.analysis_context; |
6 | 6 |
7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; | 8 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; |
9 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; | 9 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
10 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; | 10 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; |
(...skipping 11 matching lines...) Expand all Loading... |
22 AnalysisContext createAnalysisContextWithSources( | 22 AnalysisContext createAnalysisContextWithSources( |
23 StrongModeOptions strongOptions, SourceResolverOptions srcOptions, | 23 StrongModeOptions strongOptions, SourceResolverOptions srcOptions, |
24 {DartUriResolver sdkResolver, List<UriResolver> fileResolvers}) { | 24 {DartUriResolver sdkResolver, List<UriResolver> fileResolvers}) { |
25 var srcFactory = createSourceFactory(srcOptions, | 25 var srcFactory = createSourceFactory(srcOptions, |
26 sdkResolver: sdkResolver, fileResolvers: fileResolvers); | 26 sdkResolver: sdkResolver, fileResolvers: fileResolvers); |
27 return createAnalysisContext(strongOptions)..sourceFactory = srcFactory; | 27 return createAnalysisContext(strongOptions)..sourceFactory = srcFactory; |
28 } | 28 } |
29 | 29 |
30 /// Creates an analysis context that contains our restricted typing rules. | 30 /// Creates an analysis context that contains our restricted typing rules. |
31 AnalysisContext createAnalysisContext(StrongModeOptions options) { | 31 AnalysisContext createAnalysisContext(StrongModeOptions options) { |
32 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext(); | 32 AnalysisEngine.instance.useTaskModel = true; |
33 enableDevCompilerInference(res, options); | 33 var res = AnalysisEngine.instance.createAnalysisContext(); |
| 34 res.analysisOptions.strongMode = true; |
| 35 if (!AnalysisEngine.instance.useTaskModel) enableDevCompilerInference(res, opt
ions); |
34 return res; | 36 return res; |
35 } | 37 } |
36 | 38 |
37 /// Enables dev_compiler inference rules. | 39 /// Enables dev_compiler inference rules. |
38 // TODO(jmesserly): is there a cleaner way to plug this in? | 40 // TODO(jmesserly): is there a cleaner way to plug this in? |
39 void enableDevCompilerInference( | 41 void enableDevCompilerInference( |
40 AnalysisContextImpl context, StrongModeOptions options) { | 42 AnalysisContextImpl context, StrongModeOptions options) { |
41 context.libraryResolverFactory = (c) => | 43 context.libraryResolverFactory = (c) => |
42 new LibraryResolverWithInference(c, options); | 44 new LibraryResolverWithInference(c, options); |
43 } | 45 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 77 } |
76 | 78 |
77 /// Creates a [DartUriResolver] that uses a mock 'dart:' library contents. | 79 /// Creates a [DartUriResolver] that uses a mock 'dart:' library contents. |
78 DartUriResolver createMockSdkResolver(Map<String, String> mockSources) => | 80 DartUriResolver createMockSdkResolver(Map<String, String> mockSources) => |
79 new MockDartSdk(mockSources, reportMissing: true).resolver; | 81 new MockDartSdk(mockSources, reportMissing: true).resolver; |
80 | 82 |
81 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. | 83 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. |
82 DartUriResolver createSdkPathResolver(String sdkPath) => | 84 DartUriResolver createSdkPathResolver(String sdkPath) => |
83 new DartUriResolver(new DirectoryBasedDartSdk( | 85 new DartUriResolver(new DirectoryBasedDartSdk( |
84 new JavaFile(sdkPath), /*useDart2jsPaths:*/ true)); | 86 new JavaFile(sdkPath), /*useDart2jsPaths:*/ true)); |
OLD | NEW |