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

Unified Diff: pkg/analyzer/lib/source/sdk_ext.dart

Issue 1294473009: Fix script entry case of SdkExtUriResolver.restoreAbsolute (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/source/sdk_ext_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/source/sdk_ext.dart
diff --git a/pkg/analyzer/lib/source/sdk_ext.dart b/pkg/analyzer/lib/source/sdk_ext.dart
index 7caad4359c4ef100b357fa9c7f2315a3a0e7a1fa..d16bb4775ed28d1c5aaacfb7d7f903f39636e5ab 100644
--- a/pkg/analyzer/lib/source/sdk_ext.dart
+++ b/pkg/analyzer/lib/source/sdk_ext.dart
@@ -76,13 +76,25 @@ class SdkExtUriResolver extends UriResolver {
@override
Uri restoreAbsolute(Source source) {
- String libraryName = _libraryName(source.uri);
- if (_registeredSdkExtension(libraryName)) {
- return source.uri;
+ String extensionName = _findExtensionNameFor(source.fullName);
+ if (extensionName != null) {
+ return Uri.parse(extensionName);
}
+ // TODO(johnmccutchan): Handle restoring parts.
return null;
}
+ /// Return the extension name for [fullName] or `null`.
+ String _findExtensionNameFor(String fullName) {
+ var result;
+ _urlMappings.forEach((extensionName, pathMapping) {
+ if (pathMapping == fullName) {
+ result = extensionName;
+ }
+ });
+ return result;
+ }
+
/// Return the library name of [importUri].
String _libraryName(Uri importUri) {
var uri = importUri.toString();
@@ -152,11 +164,6 @@ class SdkExtUriResolver extends UriResolver {
}
}
- /// Returns true if [libraryName] is a registered sdk extension.
- bool _registeredSdkExtension(String libraryName) {
- return _urlMappings[libraryName] != null;
- }
-
/// Resolve an import of an sdk extension.
Source _resolveEntry(Uri libraryEntry, Uri importUri) {
// Library entry.
« no previous file with comments | « no previous file | pkg/analyzer/test/source/sdk_ext_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698