| 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 analyzer.src.context.source; | 5 library analyzer.src.context.source; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/physical_file_system.dart'; | 8 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 9 import 'package:analyzer/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 * The predicate to determine is [Source] is local. | 46 * The predicate to determine is [Source] is local. |
| 47 */ | 47 */ |
| 48 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; | 48 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Initialize a newly created source factory with the given absolute URI | 51 * Initialize a newly created source factory with the given absolute URI |
| 52 * [resolvers] and optional [packages] resolution helper. | 52 * [resolvers] and optional [packages] resolution helper. |
| 53 */ | 53 */ |
| 54 SourceFactoryImpl(this.resolvers, | 54 SourceFactoryImpl(this.resolvers, |
| 55 [this._packages, ResourceProvider resourceProvider]) | 55 [this._packages, ResourceProvider resourceProvider]) |
| 56 : _resourceProvider = resourceProvider != null | 56 : _resourceProvider = |
| 57 ? resourceProvider | 57 resourceProvider ?? PhysicalResourceProvider.INSTANCE; |
| 58 : PhysicalResourceProvider.INSTANCE; | |
| 59 | 58 |
| 60 /** | 59 /** |
| 61 * Return the [DartSdk] associated with this [SourceFactory], or `null` if | 60 * Return the [DartSdk] associated with this [SourceFactory], or `null` if |
| 62 * there is no such SDK. | 61 * there is no such SDK. |
| 63 * | 62 * |
| 64 * @return the [DartSdk] associated with this [SourceFactory], or `null` if | 63 * @return the [DartSdk] associated with this [SourceFactory], or `null` if |
| 65 * there is no such SDK | 64 * there is no such SDK |
| 66 */ | 65 */ |
| 67 @override | 66 @override |
| 68 DartSdk get dartSdk { | 67 DartSdk get dartSdk { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 98 _resourceProvider.getFolder(uri.toFilePath()) | 97 _resourceProvider.getFolder(uri.toFilePath()) |
| 99 ]; | 98 ]; |
| 100 } | 99 } |
| 101 }); | 100 }); |
| 102 return packageMap; | 101 return packageMap; |
| 103 } | 102 } |
| 104 | 103 |
| 105 // Default to the PackageMapUriResolver. | 104 // Default to the PackageMapUriResolver. |
| 106 PackageMapUriResolver resolver = resolvers | 105 PackageMapUriResolver resolver = resolvers |
| 107 .firstWhere((r) => r is PackageMapUriResolver, orElse: () => null); | 106 .firstWhere((r) => r is PackageMapUriResolver, orElse: () => null); |
| 108 return resolver != null ? resolver.packageMap : null; | 107 return resolver?.packageMap; |
| 109 } | 108 } |
| 110 | 109 |
| 111 /** | 110 /** |
| 112 * Return a source factory that will resolve URI's in the same way that this | 111 * Return a source factory that will resolve URI's in the same way that this |
| 113 * source factory does. | 112 * source factory does. |
| 114 */ | 113 */ |
| 115 @override | 114 @override |
| 116 SourceFactory clone() { | 115 SourceFactory clone() { |
| 117 SourceFactory factory = | 116 SourceFactory factory = |
| 118 new SourceFactory(resolvers, _packages, _resourceProvider); | 117 new SourceFactory(resolvers, _packages, _resourceProvider); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 for (UriResolver resolver in resolvers) { | 313 for (UriResolver resolver in resolvers) { |
| 315 Source result = resolver.resolveAbsolute(containedUri, actualUri); | 314 Source result = resolver.resolveAbsolute(containedUri, actualUri); |
| 316 if (result != null) { | 315 if (result != null) { |
| 317 return result; | 316 return result; |
| 318 } | 317 } |
| 319 } | 318 } |
| 320 | 319 |
| 321 return null; | 320 return null; |
| 322 } | 321 } |
| 323 } | 322 } |
| OLD | NEW |