Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: pkg/analyzer/lib/source/package_map_resolver.dart

Issue 426793002: Test for the 'importing a package library' fix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 } 78 }
79 } 79 }
80 } 80 }
81 // Return a NonExistingSource instance. 81 // Return a NonExistingSource instance.
82 // This helps provide more meaningful error messages to users 82 // This helps provide more meaningful error messages to users
83 // (a missing file error, as opposed to an invalid URI error). 83 // (a missing file error, as opposed to an invalid URI error).
84 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); 84 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI);
85 } 85 }
86 86
87 @override
88 Uri restoreAbsolute(Source source) {
89 String sourcePath = source.fullName;
90 for (String pkgName in packageMap.keys) {
91 List<Folder> pkgFolders = packageMap[pkgName];
92 for (Folder pkgFolder in pkgFolders) {
93 String pkgFolderPath = pkgFolder.path;
94 if (sourcePath.startsWith(pkgFolderPath)) {
95 String relPath = sourcePath.substring(pkgFolderPath.length);
96 return new Uri(path: '${PACKAGE_SCHEME}:$pkgName$relPath');
97 }
98 }
99 }
100 return null;
101 }
102
87 /** 103 /**
88 * Returns `true` if [uri] is a `package` URI. 104 * Returns `true` if [uri] is a `package` URI.
89 */ 105 */
90 static bool isPackageUri(Uri uri) { 106 static bool isPackageUri(Uri uri) {
91 return uri.scheme == PACKAGE_SCHEME; 107 return uri.scheme == PACKAGE_SCHEME;
92 } 108 }
93 } 109 }
OLDNEW
« no previous file with comments | « pkg/analysis_testing/lib/abstract_context.dart ('k') | pkg/analyzer/test/source/package_map_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698