| 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 | 2 |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import 'package:args/args.dart' show ArgParser, ArgResults; | 6 import 'package:args/args.dart' show ArgParser, ArgResults; |
| 7 import 'package:analyzer/file_system/file_system.dart' | 7 import 'package:analyzer/file_system/file_system.dart' |
| 8 show ResourceProvider, ResourceUriResolver; | 8 show ResourceProvider, ResourceUriResolver; |
| 9 import 'package:analyzer/file_system/physical_file_system.dart' | 9 import 'package:analyzer/file_system/physical_file_system.dart' |
| 10 show PhysicalResourceProvider; | 10 show PhysicalResourceProvider; |
| 11 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; | 11 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; |
| 12 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk; | 12 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk; |
| 13 import 'package:analyzer/src/generated/engine.dart' | 13 import 'package:analyzer/src/generated/engine.dart' |
| 14 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl; | 14 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl; |
| 15 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; | 15 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; |
| 16 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 17 import 'package:analyzer/src/generated/source_io.dart' | 17 import 'package:analyzer/src/generated/source_io.dart' |
| 18 show | 18 show |
| 19 CustomUriResolver, | 19 CustomUriResolver, |
| 20 DartUriResolver, | 20 DartUriResolver, |
| 21 PackageUriResolver, | 21 PackageUriResolver, |
| 22 SourceFactory, | 22 SourceFactory, |
| 23 UriResolver; | 23 UriResolver; |
| 24 import 'package:analyzer/src/summary/package_bundle_reader.dart' | 24 import 'package:analyzer/src/summary/package_bundle_reader.dart' |
| 25 show | 25 show InSummaryUriResolver, InputPackagesResultProvider, SummaryDataStore; |
| 26 InSummaryPackageUriResolver, | |
| 27 InputPackagesResultProvider, | |
| 28 SummaryDataStore; | |
| 29 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; | 26 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; |
| 30 import 'package:cli_util/cli_util.dart' show getSdkDir; | 27 import 'package:cli_util/cli_util.dart' show getSdkDir; |
| 31 import 'package:path/path.dart' as path; | 28 import 'package:path/path.dart' as path; |
| 32 | 29 |
| 33 import 'multi_package_resolver.dart' show MultiPackageResolver; | 30 import 'multi_package_resolver.dart' show MultiPackageResolver; |
| 34 | 31 |
| 35 /// Options used to set up Source URI resolution in the analysis context. | 32 /// Options used to set up Source URI resolution in the analysis context. |
| 36 class AnalyzerOptions { | 33 class AnalyzerOptions { |
| 37 /// Custom URI mappings, such as "dart:foo" -> "path/to/foo.dart" | 34 /// Custom URI mappings, such as "dart:foo" -> "path/to/foo.dart" |
| 38 final Map<String, String> customUrlMappings; | 35 final Map<String, String> customUrlMappings; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 {DartUriResolver sdkResolver, | 156 {DartUriResolver sdkResolver, |
| 160 List<UriResolver> fileResolvers, | 157 List<UriResolver> fileResolvers, |
| 161 SummaryDataStore summaryData, | 158 SummaryDataStore summaryData, |
| 162 ResourceProvider resourceProvider}) { | 159 ResourceProvider resourceProvider}) { |
| 163 var resolvers = <UriResolver>[]; | 160 var resolvers = <UriResolver>[]; |
| 164 if (options.customUrlMappings.isNotEmpty) { | 161 if (options.customUrlMappings.isNotEmpty) { |
| 165 resolvers.add(new CustomUriResolver(options.customUrlMappings)); | 162 resolvers.add(new CustomUriResolver(options.customUrlMappings)); |
| 166 } | 163 } |
| 167 resolvers.add(sdkResolver); | 164 resolvers.add(sdkResolver); |
| 168 if (summaryData != null) { | 165 if (summaryData != null) { |
| 169 resolvers.add(new InSummaryPackageUriResolver(summaryData)); | 166 resolvers.add(new InSummaryUriResolver(resourceProvider, summaryData)); |
| 170 } | 167 } |
| 171 | 168 |
| 172 if (fileResolvers == null) fileResolvers = createFileResolvers(options); | 169 if (fileResolvers == null) fileResolvers = createFileResolvers(options); |
| 173 resolvers.addAll(fileResolvers); | 170 resolvers.addAll(fileResolvers); |
| 174 return new SourceFactory(resolvers, null, resourceProvider); | 171 return new SourceFactory(resolvers, null, resourceProvider); |
| 175 } | 172 } |
| 176 | 173 |
| 177 List<UriResolver> createFileResolvers(AnalyzerOptions options) { | 174 List<UriResolver> createFileResolvers(AnalyzerOptions options) { |
| 178 return [ | 175 return [ |
| 179 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE), | 176 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 192 return sdk; | 189 return sdk; |
| 193 } | 190 } |
| 194 | 191 |
| 195 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. | 192 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. |
| 196 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) { | 193 DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) { |
| 197 var sdk = (sdkSummaryPath != null) | 194 var sdk = (sdkSummaryPath != null) |
| 198 ? new SummaryBasedDartSdk(sdkSummaryPath, true) | 195 ? new SummaryBasedDartSdk(sdkSummaryPath, true) |
| 199 : _createFolderBasedDartSdk(sdkPath); | 196 : _createFolderBasedDartSdk(sdkPath); |
| 200 return new DartUriResolver(sdk); | 197 return new DartUriResolver(sdk); |
| 201 } | 198 } |
| OLD | NEW |