diff --git a/modules/angular2/pubspec.yaml b/modules/angular2/pubspec.yaml index 980ce1a25f..c595adad83 100644 --- a/modules/angular2/pubspec.yaml +++ b/modules/angular2/pubspec.yaml @@ -11,7 +11,6 @@ environment: dependencies: analyzer: '>=0.24.4 <0.27.0' barback: '^0.15.2+2' - code_transformers: '0.2.9+4' dart_style: '>=0.1.8 <0.3.0' glob: '^1.0.0' html: '^0.12.0' @@ -23,6 +22,7 @@ dependencies: source_span: '^1.0.0' stack_trace: '^1.1.1' dev_dependencies: + code_transformers: '0.2.9+4' guinness: '^0.1.18' transformers: - angular2 diff --git a/modules_dart/transform/lib/src/transform/common/class_matcher_base.dart b/modules_dart/transform/lib/src/transform/common/class_matcher_base.dart index 2d4c3c2957..1db4d01f6f 100644 --- a/modules_dart/transform/lib/src/transform/common/class_matcher_base.dart +++ b/modules_dart/transform/lib/src/transform/common/class_matcher_base.dart @@ -2,9 +2,10 @@ library angular2.transform.common.class_matcher_base; import 'package:analyzer/src/generated/ast.dart'; import 'package:barback/barback.dart' show AssetId; -import 'package:code_transformers/assets.dart'; import 'package:path/path.dart' as path; + import 'logging.dart' show log; +import 'url_resolver.dart'; /// Checks if a given [Identifier] matches any of the given [ClassDescriptor]s. abstract class ClassMatcherBase { @@ -74,6 +75,7 @@ ImportDirective _getMatchingImport( name = className.name; } if (name != descriptor.name) return null; + final assetUri = toAssetUri(assetId); return (className.root as CompilationUnit) .directives .where((d) => d is ImportDirective) @@ -82,12 +84,13 @@ ImportDirective _getMatchingImport( var uriString = i.uri.stringValue; if (uriString == descriptor.import) { importMatch = true; - } else if (uriString.startsWith('package:') || - uriString.startsWith('dart:')) { + } else if (uriString.startsWith('package:') || isDartCoreUri(uriString)) { return false; } else { - importMatch = - descriptor.assetId == uriToAssetId(assetId, uriString, log, null); + final candidateAssetId = + fromUri(const TransformerUrlResolver().resolve(assetUri, uriString)); + + importMatch = descriptor.assetId == candidateAssetId; } if (!importMatch) return false; diff --git a/modules_dart/transform/lib/src/transform/directive_processor/inliner.dart b/modules_dart/transform/lib/src/transform/directive_processor/inliner.dart index c63f2852c7..ff8ff0f135 100644 --- a/modules_dart/transform/lib/src/transform/directive_processor/inliner.dart +++ b/modules_dart/transform/lib/src/transform/directive_processor/inliner.dart @@ -4,14 +4,15 @@ import 'dart:async'; import 'package:analyzer/analyzer.dart'; import 'package:analyzer/src/generated/ast.dart'; -import 'package:angular2/src/transform/common/async_string_writer.dart'; -import 'package:angular2/src/transform/common/logging.dart'; -import 'package:code_transformers/assets.dart'; -import 'package:angular2/src/transform/common/asset_reader.dart'; import 'package:barback/barback.dart' show AssetId; import 'package:source_span/source_span.dart'; import 'package:path/path.dart' as path; +import 'package:angular2/src/transform/common/asset_reader.dart'; +import 'package:angular2/src/transform/common/async_string_writer.dart'; +import 'package:angular2/src/transform/common/logging.dart'; +import 'package:angular2/src/transform/common/url_resolver.dart'; + /// Reads the code at `assetId`, inlining any `part` directives in that code. /// /// Returns `null` if the code represented by `assetId` is a `part`. @@ -50,12 +51,13 @@ Future _getAllDeclarations(AssetReader reader, AssetId assetId, var partsStart = visitor.parts.first.offset, partsEnd = visitor.parts.last.end; + final assetUri = toAssetUri(assetId); var asyncWriter = new AsyncStringWriter(code.substring(0, partsStart)); visitor.parts.forEach((partDirective) { var uri = stringLiteralToString(partDirective.uri); - var partAssetId = uriToAssetId(assetId, uri, log, null /* span */, - errorOnAbsolute: false); + var partAssetId = + fromUri(const TransformerUrlResolver().resolve(assetUri, uri)); asyncWriter.asyncPrint(reader.readAsString(partAssetId).then((partCode) { if (partCode == null || partCode.isEmpty) { log.warning('Empty part at "${partDirective.uri}. Ignoring.',