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

Side by Side Diff: pkg/code_transformers/lib/src/resolver_impl.dart

Issue 196943024: Adding some asset-related utilities to code_transformers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library code_transformer.src.resolver_impl; 5 library code_transformer.src.resolver_impl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/generated/java_io.dart'; 11 import 'package:analyzer/src/generated/java_io.dart';
12 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 12 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
13 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; 13 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
14 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
15 import 'package:barback/barback.dart'; 15 import 'package:barback/barback.dart';
16 import 'package:path/path.dart' as native_path; 16 import 'package:path/path.dart' as native_path;
17 import 'package:source_maps/refactor.dart'; 17 import 'package:source_maps/refactor.dart';
18 import 'package:source_maps/span.dart' show SourceFile, Span; 18 import 'package:source_maps/span.dart' show SourceFile, Span;
19 19
20 import 'assets.dart';
20 import 'resolver.dart'; 21 import 'resolver.dart';
21 22
22 // We should always be using url paths here since it's always Dart/pub code. 23 // We should always be using url paths here since it's always Dart/pub code.
23 final path = native_path.url; 24 final path = native_path.url;
24 25
25 /// Resolves and updates an AST based on Barback-based assets. 26 /// Resolves and updates an AST based on Barback-based assets.
26 /// 27 ///
27 /// This also provides a handful of useful APIs for traversing and working 28 /// This also provides a handful of useful APIs for traversing and working
28 /// with the resolved AST. 29 /// with the resolved AST.
29 class ResolverImpl implements Resolver { 30 class ResolverImpl implements Resolver {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 503
503 if (uri.scheme == 'package') { 504 if (uri.scheme == 'package') {
504 var segments = new List.from(uri.pathSegments); 505 var segments = new List.from(uri.pathSegments);
505 var package = segments[0]; 506 var package = segments[0];
506 segments[0] = 'lib'; 507 segments[0] = 'lib';
507 return new AssetId(package, segments.join(path.separator)); 508 return new AssetId(package, segments.join(path.separator));
508 } 509 }
509 // Dart SDK libraries do not have assets. 510 // Dart SDK libraries do not have assets.
510 if (uri.scheme == 'dart') return null; 511 if (uri.scheme == 'dart') return null;
511 512
512 if (uri.host != '' || uri.scheme != '' || path.isAbsolute(url)) { 513 return uriToAssetId(source, url, logger, span);
513 logger.error('absolute paths not allowed: "$url"', span: span);
514 return null;
515 }
516
517 var targetPath = path.normalize(
518 path.join(path.dirname(source.path), url));
519 return new AssetId(source.package, targetPath);
520 } 514 }
521 515
522 516
523 /// A completer that waits until all added [Future]s complete. 517 /// A completer that waits until all added [Future]s complete.
524 // TODO(blois): Copied from quiver. Remove from here when it gets 518 // TODO(blois): Copied from quiver. Remove from here when it gets
525 // added to dart:core. (See #6626.) 519 // added to dart:core. (See #6626.)
526 class FutureGroup<E> { 520 class FutureGroup<E> {
527 static const _FINISHED = -1; 521 static const _FINISHED = -1;
528 522
529 int _pending = 0; 523 int _pending = 0;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 561
568 /** 562 /**
569 * A Future that complets with a List of the values from all the added 563 * A Future that complets with a List of the values from all the added
570 * tasks, when they have all completed. 564 * tasks, when they have all completed.
571 * 565 *
572 * If any task fails, this Future will receive the error. Only the first 566 * If any task fails, this Future will receive the error. Only the first
573 * error will be sent to the Future. 567 * error will be sent to the Future.
574 */ 568 */
575 Future<List<E>> get future => _completer.future; 569 Future<List<E>> get future => _completer.future;
576 } 570 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698