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