| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 resolver.package; | 5 library resolver.package; |
| 6 | 6 |
| 7 import 'dart:collection'; | |
| 8 | |
| 9 import 'package:analysis_server/src/resource.dart'; | 7 import 'package:analysis_server/src/resource.dart'; |
| 10 import 'package:analyzer/src/generated/source_io.dart'; | 8 import 'package:analyzer/src/generated/source_io.dart'; |
| 11 | 9 |
| 12 | 10 |
| 13 /** | 11 /** |
| 14 * A [UriResolver] implementation for the `package:` scheme that uses a map of | 12 * A [UriResolver] implementation for the `package:` scheme that uses a map of |
| 15 * package names to their directories. | 13 * package names to their directories. |
| 16 */ | 14 */ |
| 17 class PackageMapUriResolver extends UriResolver { | 15 class PackageMapUriResolver extends UriResolver { |
| 18 /** | 16 /** |
| 19 * The name of the `package` scheme. | 17 * The name of the `package` scheme. |
| 20 */ | 18 */ |
| 21 static const String PACKAGE_SCHEME = "package"; | 19 static const String PACKAGE_SCHEME = "package"; |
| 22 | 20 |
| 23 /** | 21 /** |
| 24 * A table mapping package names to the path of the directories containing | 22 * A table mapping package names to the path of the directories containing |
| 25 * the package. | 23 * the package. |
| 26 */ | 24 */ |
| 27 final HashMap<String, List<Folder>> packageMap; | 25 final Map<String, List<Folder>> packageMap; |
| 28 | 26 |
| 29 /** | 27 /** |
| 30 * The [ResourceProvider] for this resolver. | 28 * The [ResourceProvider] for this resolver. |
| 31 */ | 29 */ |
| 32 final ResourceProvider resourceProvider; | 30 final ResourceProvider resourceProvider; |
| 33 | 31 |
| 34 /** | 32 /** |
| 35 * Create a new [PackageMapUriResolver]. | 33 * Create a new [PackageMapUriResolver]. |
| 36 * | 34 * |
| 37 * [packageMap] is a table mapping package names to the paths of the | 35 * [packageMap] is a table mapping package names to the paths of the |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); | 85 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); |
| 88 } | 86 } |
| 89 | 87 |
| 90 /** | 88 /** |
| 91 * Returns `true` if [uri] is a `package` URI. | 89 * Returns `true` if [uri] is a `package` URI. |
| 92 */ | 90 */ |
| 93 static bool isPackageUri(Uri uri) { | 91 static bool isPackageUri(Uri uri) { |
| 94 return uri.scheme == PACKAGE_SCHEME; | 92 return uri.scheme == PACKAGE_SCHEME; |
| 95 } | 93 } |
| 96 } | 94 } |
| OLD | NEW |