| 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 source.package_map_resolver; | 5 library source.package_map_resolver; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 @override | 76 @override |
| 77 Uri restoreAbsolute(Source source) { | 77 Uri restoreAbsolute(Source source) { |
| 78 String sourcePath = source.fullName; | 78 String sourcePath = source.fullName; |
| 79 for (String pkgName in packageMap.keys) { | 79 for (String pkgName in packageMap.keys) { |
| 80 List<Folder> pkgFolders = packageMap[pkgName]; | 80 List<Folder> pkgFolders = packageMap[pkgName]; |
| 81 for (Folder pkgFolder in pkgFolders) { | 81 for (Folder pkgFolder in pkgFolders) { |
| 82 String pkgFolderPath = pkgFolder.path; | 82 String pkgFolderPath = pkgFolder.path; |
| 83 if (sourcePath.startsWith(pkgFolderPath)) { | 83 if (sourcePath.startsWith(pkgFolderPath)) { |
| 84 String relPath = sourcePath.substring(pkgFolderPath.length); | 84 String relPath = sourcePath.substring(pkgFolderPath.length); |
| 85 return new Uri(path: '${PACKAGE_SCHEME}:$pkgName$relPath'); | 85 return new Uri(path: '$PACKAGE_SCHEME:$pkgName$relPath'); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 return null; | 89 return null; |
| 90 } | 90 } |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Returns `true` if [uri] is a `package` URI. | 93 * Returns `true` if [uri] is a `package` URI. |
| 94 */ | 94 */ |
| 95 static bool isPackageUri(Uri uri) { | 95 static bool isPackageUri(Uri uri) { |
| 96 return uri.scheme == PACKAGE_SCHEME; | 96 return uri.scheme == PACKAGE_SCHEME; |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |