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

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

Issue 174313004: Fixing non-posix path issue on Window (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/error.dart'; 11 import 'package:analyzer/src/generated/error.dart';
12 import 'package:analyzer/src/generated/java_io.dart'; 12 import 'package:analyzer/src/generated/java_io.dart';
13 import 'package:analyzer/src/generated/parser.dart' show Parser; 13 import 'package:analyzer/src/generated/parser.dart' show Parser;
14 import 'package:analyzer/src/generated/scanner.dart'; 14 import 'package:analyzer/src/generated/scanner.dart';
15 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 15 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
16 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; 16 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
17 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
18 import 'package:barback/barback.dart'; 18 import 'package:barback/barback.dart';
19 import 'package:path/path.dart' as path; 19 import 'package:path/path.dart' as native_path;
20 import 'package:source_maps/refactor.dart'; 20 import 'package:source_maps/refactor.dart';
21 import 'package:source_maps/span.dart' show SourceFile, Span; 21 import 'package:source_maps/span.dart' show SourceFile, Span;
22 22
23 import 'resolver.dart'; 23 import 'resolver.dart';
24 24
25 // We should always be using url paths here since it's always Dart/pub code.
26 final path = native_path.url;
27
25 /// Resolves and updates an AST based on Barback-based assets. 28 /// Resolves and updates an AST based on Barback-based assets.
26 /// 29 ///
27 /// This also provides a handful of useful APIs for traversing and working 30 /// This also provides a handful of useful APIs for traversing and working
28 /// with the resolved AST. 31 /// with the resolved AST.
29 class ResolverImpl implements Resolver { 32 class ResolverImpl implements Resolver {
30 /// Cache of all asset sources currently referenced. 33 /// Cache of all asset sources currently referenced.
31 final Map<AssetId, _AssetBasedSource> sources = 34 final Map<AssetId, _AssetBasedSource> sources =
32 <AssetId, _AssetBasedSource>{}; 35 <AssetId, _AssetBasedSource>{};
33 36
34 /// The Dart entry point file where parsing begins. 37 /// The Dart entry point file where parsing begins.
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 462
460 UriKind get uriKind => _proxy.uriKind; 463 UriKind get uriKind => _proxy.uriKind;
461 464
462 bool get isInSystemLibrary => _proxy.isInSystemLibrary; 465 bool get isInSystemLibrary => _proxy.isInSystemLibrary;
463 } 466 }
464 467
465 /// Get an asset ID for a URL relative to another source asset. 468 /// Get an asset ID for a URL relative to another source asset.
466 AssetId _resolve(AssetId source, String url, TransformLogger logger, 469 AssetId _resolve(AssetId source, String url, TransformLogger logger,
467 Span span) { 470 Span span) {
468 if (url == null || url == '') return null; 471 if (url == null || url == '') return null;
469 var urlBuilder = path.url;
470 var uri = Uri.parse(url); 472 var uri = Uri.parse(url);
471 473
472 if (uri.scheme == 'package') { 474 if (uri.scheme == 'package') {
473 var segments = new List.from(uri.pathSegments); 475 var segments = new List.from(uri.pathSegments);
474 var package = segments[0]; 476 var package = segments[0];
475 segments[0] = 'lib'; 477 segments[0] = 'lib';
476 return new AssetId(package, segments.join(urlBuilder.separator)); 478 return new AssetId(package, segments.join(path.separator));
477 } 479 }
478 // Dart SDK libraries do not have assets. 480 // Dart SDK libraries do not have assets.
479 if (uri.scheme == 'dart') return null; 481 if (uri.scheme == 'dart') return null;
480 482
481 if (uri.host != '' || uri.scheme != '' || urlBuilder.isAbsolute(url)) { 483 if (uri.host != '' || uri.scheme != '' || path.isAbsolute(url)) {
482 logger.error('absolute paths not allowed: "$url"', span: span); 484 logger.error('absolute paths not allowed: "$url"', span: span);
483 return null; 485 return null;
484 } 486 }
485 487
486 var targetPath = urlBuilder.normalize( 488 var targetPath = path.normalize(
487 urlBuilder.join(urlBuilder.dirname(source.path), url)); 489 path.join(path.dirname(source.path), url));
488 return new AssetId(source.package, targetPath); 490 return new AssetId(source.package, targetPath);
489 } 491 }
490 492
491 493
492 /// A completer that waits until all added [Future]s complete. 494 /// A completer that waits until all added [Future]s complete.
493 // TODO(blois): Copied from quiver. Remove from here when it gets 495 // TODO(blois): Copied from quiver. Remove from here when it gets
494 // added to dart:core. (See #6626.) 496 // added to dart:core. (See #6626.)
495 class FutureGroup<E> { 497 class FutureGroup<E> {
496 static const _FINISHED = -1; 498 static const _FINISHED = -1;
497 499
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 538
537 /** 539 /**
538 * A Future that complets with a List of the values from all the added 540 * A Future that complets with a List of the values from all the added
539 * tasks, when they have all completed. 541 * tasks, when they have all completed.
540 * 542 *
541 * If any task fails, this Future will receive the error. Only the first 543 * If any task fails, this Future will receive the error. Only the first
542 * error will be sent to the Future. 544 * error will be sent to the Future.
543 */ 545 */
544 Future<List<E>> get future => _completer.future; 546 Future<List<E>> get future => _completer.future;
545 } 547 }
OLDNEW
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698