| 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 'package:analysis_server/src/resource.dart'; | 7 import 'package:analysis_server/src/resource.dart'; |
| 8 import 'package:analyzer/src/generated/source_io.dart'; | 8 import 'package:analyzer/src/generated/source_io.dart'; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 /** | 32 /** |
| 33 * Create a new [PackageMapUriResolver]. | 33 * Create a new [PackageMapUriResolver]. |
| 34 * | 34 * |
| 35 * [packageMap] is a table mapping package names to the path of the directory | 35 * [packageMap] is a table mapping package names to the path of the directory |
| 36 * containing the package | 36 * containing the package |
| 37 */ | 37 */ |
| 38 PackageMapUriResolver(this.resourceProvider, this.packageMap); | 38 PackageMapUriResolver(this.resourceProvider, this.packageMap); |
| 39 | 39 |
| 40 @override | 40 @override |
| 41 Source fromEncoding(UriKind kind, Uri uri) { | 41 Source fromEncoding(UriKind kind, Uri uri) { |
| 42 if (kind == UriKind.PACKAGE_SELF_URI || kind == UriKind.PACKAGE_URI) { | 42 if (kind == UriKind.PACKAGE_URI) { |
| 43 Resource resource = resourceProvider.getResource(uri.path); | 43 Resource resource = resourceProvider.getResource(uri.path); |
| 44 if (resource is File) { | 44 if (resource is File) { |
| 45 return resource.createSource(kind); | 45 return resource.createSource(kind); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 return null; | 48 return null; |
| 49 } | 49 } |
| 50 | 50 |
| 51 @override | 51 @override |
| 52 Source resolveAbsolute(Uri uri) { | 52 Source resolveAbsolute(Uri uri) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 81 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); | 81 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Returns `true` if [uri] is a `package` URI. | 85 * Returns `true` if [uri] is a `package` URI. |
| 86 */ | 86 */ |
| 87 static bool isPackageUri(Uri uri) { | 87 static bool isPackageUri(Uri uri) { |
| 88 return uri.scheme == PACKAGE_SCHEME; | 88 return uri.scheme == PACKAGE_SCHEME; |
| 89 } | 89 } |
| 90 } | 90 } |
| OLD | NEW |