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

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/analyzer.dart' show parseCompilationUnit; 8 import 'package:analyzer/analyzer.dart' show parseCompilationUnit;
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/error.dart'; 12 import 'package:analyzer/src/generated/error.dart';
13 import 'package:analyzer/src/generated/java_io.dart'; 13 import 'package:analyzer/src/generated/java_io.dart';
14 import 'package:analyzer/src/generated/parser.dart'; 14 import 'package:analyzer/src/generated/parser.dart';
15 import 'package:analyzer/src/generated/scanner.dart'; 15 import 'package:analyzer/src/generated/scanner.dart';
16 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 16 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
17 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; 17 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
18 import 'package:analyzer/src/generated/source.dart'; 18 import 'package:analyzer/src/generated/source.dart';
19 import 'package:barback/barback.dart'; 19 import 'package:barback/barback.dart';
20 import 'package:code_transformers/assets.dart';
20 import 'package:path/path.dart' as native_path; 21 import 'package:path/path.dart' as native_path;
21 import 'package:source_maps/refactor.dart'; 22 import 'package:source_maps/refactor.dart';
22 import 'package:source_maps/span.dart' show SourceFile, Span; 23 import 'package:source_maps/span.dart' show SourceFile, Span;
23 24
24 import 'resolver.dart'; 25 import 'resolver.dart';
25 26
26 // We should always be using url paths here since it's always Dart/pub code. 27 // We should always be using url paths here since it's always Dart/pub code.
27 final path = native_path.url; 28 final path = native_path.url;
28 29
29 /// Resolves and updates an AST based on Barback-based assets. 30 /// Resolves and updates an AST based on Barback-based assets.
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 508
508 if (uri.scheme == 'package') { 509 if (uri.scheme == 'package') {
509 var segments = new List.from(uri.pathSegments); 510 var segments = new List.from(uri.pathSegments);
510 var package = segments[0]; 511 var package = segments[0];
511 segments[0] = 'lib'; 512 segments[0] = 'lib';
512 return new AssetId(package, segments.join(path.separator)); 513 return new AssetId(package, segments.join(path.separator));
513 } 514 }
514 // Dart SDK libraries do not have assets. 515 // Dart SDK libraries do not have assets.
515 if (uri.scheme == 'dart') return null; 516 if (uri.scheme == 'dart') return null;
516 517
517 if (uri.host != '' || uri.scheme != '' || path.isAbsolute(url)) { 518 return uriToAssetId(source, url, logger, span);
518 logger.error('absolute paths not allowed: "$url"', span: span);
519 return null;
520 }
521
522 var targetPath = path.normalize(
523 path.join(path.dirname(source.path), url));
524 return new AssetId(source.package, targetPath);
525 } 519 }
526 520
527 521
528 /// A completer that waits until all added [Future]s complete. 522 /// A completer that waits until all added [Future]s complete.
529 // TODO(blois): Copied from quiver. Remove from here when it gets 523 // TODO(blois): Copied from quiver. Remove from here when it gets
530 // added to dart:core. (See #6626.) 524 // added to dart:core. (See #6626.)
531 class FutureGroup<E> { 525 class FutureGroup<E> {
532 static const _FINISHED = -1; 526 static const _FINISHED = -1;
533 527
534 int _pending = 0; 528 int _pending = 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 586
593 void apply(ChangeSet changeSet) { 587 void apply(ChangeSet changeSet) {
594 if (!source.updateContents(content)) return; 588 if (!source.updateContents(content)) return;
595 if (source._revision == 1 && source._contents != null) { 589 if (source._revision == 1 && source._contents != null) {
596 changeSet.addedSource(source); 590 changeSet.addedSource(source);
597 } else { 591 } else {
598 changeSet.changedSource(source); 592 changeSet.changedSource(source);
599 } 593 }
600 } 594 }
601 } 595 }
OLDNEW
« no previous file with comments | « pkg/code_transformers/lib/src/entry_point.dart ('k') | pkg/code_transformers/test/assets_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698