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

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

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
Index: packages/analyzer/lib/source/sdk_ext.dart
diff --git a/analyzer/lib/source/sdk_ext.dart b/packages/analyzer/lib/source/sdk_ext.dart
similarity index 88%
rename from analyzer/lib/source/sdk_ext.dart
rename to packages/analyzer/lib/source/sdk_ext.dart
index 696e181998c719f4b22b7531cad4006083200977..646a19fc60404eaf3e454395623da205522f3b32 100644
--- a/analyzer/lib/source/sdk_ext.dart
+++ b/packages/analyzer/lib/source/sdk_ext.dart
@@ -27,7 +27,7 @@ class SdkExtUriResolver extends UriResolver {
static const String SDK_EXT_NAME = '_sdkext';
static const String DART_COLON_PREFIX = 'dart:';
- final Map<String, String> _urlMappings = <String,String>{};
+ final Map<String, String> _urlMappings = <String, String>{};
/// Construct a [SdkExtUriResolver] from a package map
/// (see [PackageMapProvider]).
@@ -42,7 +42,7 @@ class SdkExtUriResolver extends UriResolver {
int get length => _urlMappings.length;
/// Return the path mapping for [libName] or null if there is none.
- String operator[](String libName) => _urlMappings[libName];
+ String operator [](String libName) => _urlMappings[libName];
/// Programmatically add a new SDK extension given a JSON description
/// ([sdkExtJSON]) and a lib directory ([libDir]).
@@ -51,7 +51,7 @@ class SdkExtUriResolver extends UriResolver {
}
@override
- Source resolveAbsolute(Uri importUri) {
+ Source resolveAbsolute(Uri importUri, [Uri actualUri]) {
String libraryName = _libraryName(importUri);
String partPath = _partPath(importUri);
// Lookup library name in mappings.
@@ -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 | « packages/analyzer/lib/source/pub_package_map_provider.dart ('k') | packages/analyzer/lib/src/cancelable_future.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698