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

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

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/transformer_id.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/barback/transformer_id.dart b/sdk/lib/_internal/pub_generated/lib/src/barback/transformer_id.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c209c70e8cec63d3e130130d874e1af40c0203ad
--- /dev/null
+++ b/sdk/lib/_internal/pub_generated/lib/src/barback/transformer_id.dart
@@ -0,0 +1,53 @@
+library pub.barback.transformer_id;
+import 'dart:async';
+import 'package:barback/barback.dart';
+import 'package:path/path.dart' as p;
+import 'package:source_span/source_span.dart';
+import '../io.dart';
+import '../utils.dart';
+const _BUILT_IN_TRANSFORMERS = const ['\$dart2js'];
+class TransformerId {
+ final String package;
+ final String path;
+ final SourceSpan span;
+ bool get isBuiltInTransformer => package.startsWith('\$');
+ factory TransformerId.parse(String identifier, SourceSpan span) {
+ if (identifier.isEmpty) {
+ throw new FormatException('Invalid library identifier: "".');
+ }
+ var parts = split1(identifier, "/");
+ if (parts.length == 1) {
+ return new TransformerId(parts.single, null, span);
+ }
+ return new TransformerId(parts.first, parts.last, span);
+ }
+ TransformerId(this.package, this.path, this.span) {
+ if (!package.startsWith('\$')) return;
+ if (_BUILT_IN_TRANSFORMERS.contains(package)) return;
+ throw new SourceSpanFormatException(
+ 'Unsupported built-in transformer $package.',
+ span);
+ }
+ bool operator ==(other) =>
+ other is TransformerId && other.package == package && other.path == path;
+ int get hashCode => package.hashCode ^ path.hashCode;
+ String toString() => path == null ? package : '$package/$path';
+ Future<AssetId> getAssetId(Barback barback) {
+ if (path != null) {
+ return new Future.value(new AssetId(package, 'lib/$path.dart'));
+ }
+ var transformerAsset = new AssetId(package, 'lib/transformer.dart');
+ return barback.getAssetById(
+ transformerAsset).then(
+ (_) =>
+ transformerAsset).catchError(
+ (e) => new AssetId(package, 'lib/$package.dart'),
+ test: (e) => e is AssetNotFoundException);
+ }
+ String getFullPath(String packageDir) {
+ if (path != null) return p.join(packageDir, 'lib', p.fromUri('$path.dart'));
+ var transformerPath = p.join(packageDir, 'lib', 'transformer.dart');
+ if (fileExists(transformerPath)) return transformerPath;
+ return p.join(packageDir, 'lib', '$package.dart');
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698