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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart

Issue 198053009: Use real "package:" imports in pub's plugin-loading code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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: sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart b/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart
index 9e1d7b43c48d532585b95a56dc1c59416705af38..7740ba60f450c4c165ecdc4880b04a984a2f27bc 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart
@@ -10,18 +10,32 @@ import 'package:barback/barback.dart';
import 'package:path/path.dart' as path;
import '../package_graph.dart';
+import '../io.dart';
/// An implementation of barback's [PackageProvider] interface so that barback
/// can find assets within pub packages.
class PubPackageProvider implements PackageProvider {
final PackageGraph _graph;
+ final List<String> packages;
- PubPackageProvider(this._graph);
-
- Iterable<String> get packages => _graph.packages.keys;
+ PubPackageProvider(PackageGraph graph)
+ : _graph = graph,
+ packages = new List.from(graph.packages.keys)..add(r"$pub");
Future<Asset> getAsset(AssetId id) {
- var file = path.join(_graph.packages[id.package].dir, id.path);
+ if (id.package != r'$pub') {
+ var nativePath = path.joinAll(path.url.split(id.path));
+ var file = path.join(_graph.packages[id.package].dir, nativePath);
+ return new Future.value(new Asset.fromPath(id, file));
+ }
+
+ // "$pub" is a psuedo-package that allows pub's transformer-loading
+ // infrastructure to share code with pub proper.
+ var components = path.url.split(id.path);
+ assert(components.isNotEmpty);
+ assert(components.first == 'lib');
+ components[0] = 'dart';
+ var file = assetPath(path.joinAll(components));
return new Future.value(new Asset.fromPath(id, file));
}
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart ('k') | sdk/lib/_internal/pub/lib/src/barback/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698