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

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

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 5 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/packages/analyzer/lib/source/sdk_ext.dart b/packages/analyzer/lib/source/sdk_ext.dart
index 646a19fc60404eaf3e454395623da205522f3b32..70682eb6db7d811f6461d859d4ce6ae1b7682d7d 100644
--- a/packages/analyzer/lib/source/sdk_ext.dart
+++ b/packages/analyzer/lib/source/sdk_ext.dart
@@ -2,12 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library source.sdk_ext;
+library analyzer.source.sdk_ext;
import 'dart:convert';
-import 'dart:core' hide Resource;
+import 'dart:core';
import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/source/package_map_provider.dart'
+ show PackageMapProvider;
import 'package:analyzer/src/generated/java_io.dart' show JavaFile;
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart' show FileBasedSource;
@@ -29,6 +31,12 @@ class SdkExtUriResolver extends UriResolver {
final Map<String, String> _urlMappings = <String, String>{};
+ /**
+ * The absolute paths of the extension files that contributed to the
+ * [_urlMappings].
+ */
+ final List<String> extensionFilePaths = <String>[];
+
/// Construct a [SdkExtUriResolver] from a package map
/// (see [PackageMapProvider]).
SdkExtUriResolver(Map<String, List<Folder>> packageMap) {
@@ -41,6 +49,13 @@ class SdkExtUriResolver extends UriResolver {
/// Number of sdk extensions.
int get length => _urlMappings.length;
+ /**
+ * Return a table mapping the names of extensions to the paths where those
+ * extensions can be found.
+ */
+ Map<String, String> get urlMappings =>
+ new Map<String, String>.from(_urlMappings);
+
/// Return the path mapping for [libName] or null if there is none.
String operator [](String libName) => _urlMappings[libName];
@@ -138,24 +153,33 @@ class SdkExtUriResolver extends UriResolver {
if ((sdkExt == null) || (sdkExt is! Map)) {
return;
}
- sdkExt.forEach((k, v) => _processSdkExtension(k, v, libDir));
+ bool contributed = false;
+ sdkExt.forEach((k, v) {
+ if (_processSdkExtension(k, v, libDir)) {
+ contributed = true;
+ }
+ });
+ if (contributed) {
+ extensionFilePaths.add(libDir.getChild(SDK_EXT_NAME).path);
+ }
}
/// Install the mapping from [name] to [libDir]/[file].
- void _processSdkExtension(String name, String file, Folder libDir) {
+ bool _processSdkExtension(String name, String file, Folder libDir) {
if (!name.startsWith(DART_COLON_PREFIX)) {
// SDK extensions must begin with 'dart:'.
- return;
+ return false;
}
var key = name;
var value = libDir.canonicalizePath(file);
_urlMappings[key] = value;
+ return true;
}
/// Read the contents of [libDir]/[SDK_EXT_NAME] as a string.
/// Returns null if the file doesn't exist.
String _readDotSdkExt(Folder libDir) {
- var file = libDir.getChild(SDK_EXT_NAME);
+ File file = libDir.getChild(SDK_EXT_NAME);
try {
return file.readAsStringSync();
} on FileSystemException {
« 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