| 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 20 matching lines...) Expand all Loading... |
| 31 AnalysisContext createAnalysisContext(StrongModeOptions options) { | 31 AnalysisContext createAnalysisContext(StrongModeOptions options) { |
| 32 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext(); | 32 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext(); |
| 33 enableDevCompilerInference(res, options); | 33 enableDevCompilerInference(res, options); |
| 34 return res; | 34 return res; |
| 35 } | 35 } |
| 36 | 36 |
| 37 /// Enables dev_compiler inference rules. | 37 /// Enables dev_compiler inference rules. |
| 38 // TODO(jmesserly): is there a cleaner way to plug this in? | 38 // TODO(jmesserly): is there a cleaner way to plug this in? |
| 39 void enableDevCompilerInference( | 39 void enableDevCompilerInference( |
| 40 AnalysisContextImpl context, StrongModeOptions options) { | 40 AnalysisContextImpl context, StrongModeOptions options) { |
| 41 context.libraryResolverFactory = | 41 context.libraryResolverFactory = (c) => |
| 42 (c) => new LibraryResolverWithInference(c, options); | 42 new LibraryResolverWithInference(c, options); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /// Creates a SourceFactory configured by the [options]. | 45 /// Creates a SourceFactory configured by the [options]. |
| 46 /// | 46 /// |
| 47 /// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver] | 47 /// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver] |
| 48 /// to entirely override the DartUriResolver. | 48 /// to entirely override the DartUriResolver. |
| 49 /// | 49 /// |
| 50 /// If supplied, [fileResolvers] will override the default `file:` and | 50 /// If supplied, [fileResolvers] will override the default `file:` and |
| 51 /// `package:` URI resolvers. | 51 /// `package:` URI resolvers. |
| 52 SourceFactory createSourceFactory(SourceResolverOptions options, | 52 SourceFactory createSourceFactory(SourceResolverOptions options, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 72 ? new MultiPackageResolver(options.packagePaths) | 72 ? new MultiPackageResolver(options.packagePaths) |
| 73 : new PackageUriResolver([new JavaFile(options.packageRoot)]) | 73 : new PackageUriResolver([new JavaFile(options.packageRoot)]) |
| 74 ]; | 74 ]; |
| 75 } | 75 } |
| 76 | 76 |
| 77 /// Creates a [DartUriResolver] that uses a mock 'dart:' library contents. | 77 /// Creates a [DartUriResolver] that uses a mock 'dart:' library contents. |
| 78 DartUriResolver createMockSdkResolver(Map<String, String> mockSources) => | 78 DartUriResolver createMockSdkResolver(Map<String, String> mockSources) => |
| 79 new MockDartSdk(mockSources, reportMissing: true).resolver; | 79 new MockDartSdk(mockSources, reportMissing: true).resolver; |
| 80 | 80 |
| 81 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. | 81 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. |
| 82 DartUriResolver createSdkPathResolver(String sdkPath) => new DartUriResolver( | 82 DartUriResolver createSdkPathResolver(String sdkPath) => |
| 83 new DirectoryBasedDartSdk( | 83 new DartUriResolver(new DirectoryBasedDartSdk( |
| 84 new JavaFile(sdkPath), /*useDart2jsPaths:*/ true)); | 84 new JavaFile(sdkPath), /*useDart2jsPaths:*/ true)); |
| OLD | NEW |