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 import 'package:analyzer/src/generated/engine.dart'; | 5 import 'package:analyzer/src/generated/engine.dart'; |
6 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; | 6 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; |
7 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; | 7 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
8 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; | 8 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; |
9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 /// Creates a SourceFactory configured by the [options]. | 34 /// Creates a SourceFactory configured by the [options]. |
35 /// | 35 /// |
36 /// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver] | 36 /// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver] |
37 /// to entirely override the DartUriResolver. | 37 /// to entirely override the DartUriResolver. |
38 /// | 38 /// |
39 /// If supplied, [fileResolvers] will override the default `file:` and | 39 /// If supplied, [fileResolvers] will override the default `file:` and |
40 /// `package:` URI resolvers. | 40 /// `package:` URI resolvers. |
41 SourceFactory createSourceFactory(SourceResolverOptions options, | 41 SourceFactory createSourceFactory(SourceResolverOptions options, |
42 {DartUriResolver sdkResolver, List<UriResolver> fileResolvers}) { | 42 {DartUriResolver sdkResolver, List<UriResolver> fileResolvers}) { |
43 var sdkResolver = options.useMockSdk | 43 sdkResolver ??= options.useMockSdk |
vsm
2016/03/29 22:10:54
doh!
| |
44 ? createMockSdkResolver(mockSdkSources) | 44 ? createMockSdkResolver(mockSdkSources) |
45 : createSdkPathResolver(options.dartSdkPath); | 45 : createSdkPathResolver(options.dartSdkPath); |
46 | 46 |
47 var resolvers = <UriResolver>[]; | 47 var resolvers = <UriResolver>[]; |
48 if (options.customUrlMappings.isNotEmpty) { | 48 if (options.customUrlMappings.isNotEmpty) { |
49 resolvers.add(new CustomUriResolver(options.customUrlMappings)); | 49 resolvers.add(new CustomUriResolver(options.customUrlMappings)); |
50 } | 50 } |
51 resolvers.add(sdkResolver); | 51 resolvers.add(sdkResolver); |
52 if (fileResolvers == null) fileResolvers = createFileResolvers(options); | 52 if (fileResolvers == null) fileResolvers = createFileResolvers(options); |
53 resolvers.addAll(fileResolvers); | 53 resolvers.addAll(fileResolvers); |
(...skipping 13 matching lines...) Expand all Loading... | |
67 DartUriResolver createMockSdkResolver(Map<String, String> mockSources) => | 67 DartUriResolver createMockSdkResolver(Map<String, String> mockSources) => |
68 new MockDartSdk(mockSources, reportMissing: true).resolver; | 68 new MockDartSdk(mockSources, reportMissing: true).resolver; |
69 | 69 |
70 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. | 70 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. |
71 DartUriResolver createSdkPathResolver(String sdkPath) { | 71 DartUriResolver createSdkPathResolver(String sdkPath) { |
72 var sdk = new DirectoryBasedDartSdk( | 72 var sdk = new DirectoryBasedDartSdk( |
73 new JavaFile(sdkPath), /*useDart2jsPaths:*/ true); | 73 new JavaFile(sdkPath), /*useDart2jsPaths:*/ true); |
74 sdk.context.analysisOptions.strongMode = true; | 74 sdk.context.analysisOptions.strongMode = true; |
75 return new DartUriResolver(sdk); | 75 return new DartUriResolver(sdk); |
76 } | 76 } |
OLD | NEW |