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

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

Issue 657673002: Regenerate pub sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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: sdk/lib/_internal/pub_generated/lib/src/barback/pub_package_provider.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/barback/pub_package_provider.dart b/sdk/lib/_internal/pub_generated/lib/src/barback/pub_package_provider.dart
index 77807e755189c228576f7e6297ccc432b34c165f..d82da67d87dd3569232fcfd2d58c8bbb1c8e83f3 100644
--- a/sdk/lib/_internal/pub_generated/lib/src/barback/pub_package_provider.dart
+++ b/sdk/lib/_internal/pub_generated/lib/src/barback/pub_package_provider.dart
@@ -1,22 +1,35 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// 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 pub.pub_package_provider;
+
import 'dart:async';
+
import 'package:barback/barback.dart';
import 'package:path/path.dart' as path;
+
import '../io.dart';
import '../package_graph.dart';
import '../preprocess.dart';
import '../sdk.dart' as sdk;
import '../utils.dart';
+
+/// An implementation of barback's [PackageProvider] interface so that barback
+/// can find assets within pub packages.
class PubPackageProvider implements StaticPackageProvider {
final PackageGraph _graph;
final List<String> staticPackages;
+
Iterable<String> get packages =>
_graph.packages.keys.toSet().difference(staticPackages.toSet());
+
PubPackageProvider(PackageGraph graph)
: _graph = graph,
staticPackages = [
r"$pub",
r"$sdk"]..addAll(graph.packages.keys.where(graph.isPackageStatic));
+
Future<Asset> getAsset(AssetId id) {
final completer0 = new Completer();
scheduleMicrotask(() {
@@ -47,8 +60,9 @@ class PubPackageProvider implements StaticPackageProvider {
var file = assetPath(path.joinAll(components));
_assertExists(file, id);
join2() {
- var versions =
- mapMap(_graph.packages, value: ((_, package) => package.version));
+ var versions = mapMap(_graph.packages, value: ((_, package) {
+ return package.version;
+ }));
var contents = readTextFile(file);
contents = preprocess(contents, versions, path.toUri(file));
completer0.complete(new Asset.fromString(id, contents));
@@ -61,27 +75,34 @@ class PubPackageProvider implements StaticPackageProvider {
} else {
join0();
}
- } catch (e0) {
- completer0.completeError(e0);
+ } catch (e, s) {
+ completer0.completeError(e, s);
}
});
return completer0.future;
}
+
+ /// Throw an [AssetNotFoundException] for [id] if [path] doesn't exist.
void _assertExists(String path, AssetId id) {
if (!fileExists(path)) throw new AssetNotFoundException(id);
}
+
Stream<AssetId> getAllAssetIds(String packageName) {
if (packageName == r'$pub') {
+ // "$pub" is a pseudo-package that allows pub's transformer-loading
+ // infrastructure to share code with pub proper. We provide it only during
+ // the initial transformer loading process.
var dartPath = assetPath('dart');
return new Stream.fromIterable(
- listDir(
- dartPath,
- recursive: true).where(
- (file) => path.extension(file) == ".dart").map((library) {
+ listDir(dartPath, recursive: true)// Don't include directories.
+ .where((file) => path.extension(file) == ".dart").map((library) {
var idPath = path.join('lib', path.relative(library, from: dartPath));
return new AssetId('\$pub', path.toUri(idPath).toString());
}));
} else if (packageName == r'$sdk') {
+ // "$sdk" is a pseudo-package that allows the dart2js transformer to find
+ // the Dart core libraries without hitting the file system directly. This
+ // ensures they work with source maps.
var libPath = path.join(sdk.rootDirectory, "lib");
return new Stream.fromIterable(
listDir(

Powered by Google App Engine
This is Rietveld 408576698