| OLD | NEW |
| 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 import 'package:barback/barback.dart'; | 5 import 'package:barback/barback.dart'; |
| 6 import 'package:path/path.dart' as p; | 6 import 'package:path/path.dart' as p; |
| 7 | 7 |
| 8 import '../dart.dart'; | 8 import '../dart.dart'; |
| 9 import '../io.dart'; | 9 import '../io.dart'; |
| 10 import '../package.dart'; | 10 import '../package.dart'; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 /// This graph is represented by a map whose keys are the vertices and whose | 62 /// This graph is represented by a map whose keys are the vertices and whose |
| 63 /// values are sets representing edges from the given vertex. Each vertex is a | 63 /// values are sets representing edges from the given vertex. Each vertex is a |
| 64 /// [TransformerId]. If there's an edge from `T1` to `T2`, then `T2` must be | 64 /// [TransformerId]. If there's an edge from `T1` to `T2`, then `T2` must be |
| 65 /// loaded before `T1` can be loaded. | 65 /// loaded before `T1` can be loaded. |
| 66 /// | 66 /// |
| 67 /// The returned graph is transitively closed. That is, if there's an edge | 67 /// The returned graph is transitively closed. That is, if there's an edge |
| 68 /// from `T1` to `T2` and an edge from `T2` to `T3`, there's also an edge from | 68 /// from `T1` to `T2` and an edge from `T2` to `T3`, there's also an edge from |
| 69 /// `T1` to `T2`. | 69 /// `T1` to `T2`. |
| 70 Map<TransformerId, Set<TransformerId>> transformersNeededByTransformers( | 70 Map<TransformerId, Set<TransformerId>> transformersNeededByTransformers( |
| 71 [Iterable<TransformerId> transformers]) { | 71 [Iterable<TransformerId> transformers]) { |
| 72 var result = {}; | 72 var result = <TransformerId, Set<TransformerId>>{}; |
| 73 | 73 |
| 74 if (transformers == null) { | 74 if (transformers == null) { |
| 75 transformers = ordered(_graph.packages.keys).expand((packageName) { | 75 transformers = ordered(_graph.packages.keys).expand((packageName) { |
| 76 var package = _graph.packages[packageName]; | 76 var package = _graph.packages[packageName]; |
| 77 return package.pubspec.transformers.expand((phase) { | 77 return package.pubspec.transformers.expand((phase) { |
| 78 return phase.expand((config) { | 78 return phase.expand((config) { |
| 79 var id = config.id; | 79 var id = config.id; |
| 80 if (id.isBuiltInTransformer) return []; | 80 if (id.isBuiltInTransformer) return []; |
| 81 if (package.name != _graph.entrypoint.root.name && | 81 if (package.name != _graph.entrypoint.root.name && |
| 82 !config.canTransformPublicFiles) { | 82 !config.canTransformPublicFiles) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 /// (transitively) imports a transformed library. The result of the | 155 /// (transitively) imports a transformed library. The result of the |
| 156 /// transformation may import any dependency or hit any transformer, so we | 156 /// transformation may import any dependency or hit any transformer, so we |
| 157 /// have to assume that it will. | 157 /// have to assume that it will. |
| 158 Set<TransformerId> _transformersNeededByPackage(String rootPackage) { | 158 Set<TransformerId> _transformersNeededByPackage(String rootPackage) { |
| 159 if (_untransformedPackages.contains(rootPackage)) return new Set(); | 159 if (_untransformedPackages.contains(rootPackage)) return new Set(); |
| 160 | 160 |
| 161 if (_transformersNeededByPackages.containsKey(rootPackage)) { | 161 if (_transformersNeededByPackages.containsKey(rootPackage)) { |
| 162 return _transformersNeededByPackages[rootPackage]; | 162 return _transformersNeededByPackages[rootPackage]; |
| 163 } | 163 } |
| 164 | 164 |
| 165 var results = new Set(); | 165 var results = new Set<TransformerId>(); |
| 166 var seen = new Set(); | 166 var seen = new Set<String>(); |
| 167 | 167 |
| 168 traversePackage(packageName) { | 168 traversePackage(packageName) { |
| 169 if (seen.contains(packageName)) return; | 169 if (seen.contains(packageName)) return; |
| 170 seen.add(packageName); | 170 seen.add(packageName); |
| 171 | 171 |
| 172 var package = _graph.packages[packageName]; | 172 var package = _graph.packages[packageName]; |
| 173 for (var phase in package.pubspec.transformers) { | 173 for (var phase in package.pubspec.transformers) { |
| 174 for (var config in phase) { | 174 for (var config in phase) { |
| 175 var id = config.id; | 175 var id = config.id; |
| 176 if (id.isBuiltInTransformer) continue; | 176 if (id.isBuiltInTransformer) continue; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 /// will be URIs for this package. | 382 /// will be URIs for this package. |
| 383 /// | 383 /// |
| 384 /// If [rootLibrary] transitively imports or exports a library that's modified | 384 /// If [rootLibrary] transitively imports or exports a library that's modified |
| 385 /// by a transformer, this will return `null`. | 385 /// by a transformer, this will return `null`. |
| 386 Set<Uri> _getTransitiveExternalDirectives(String rootLibrary) { | 386 Set<Uri> _getTransitiveExternalDirectives(String rootLibrary) { |
| 387 rootLibrary = p.normalize(rootLibrary); | 387 rootLibrary = p.normalize(rootLibrary); |
| 388 if (_transitiveExternalDirectives.containsKey(rootLibrary)) { | 388 if (_transitiveExternalDirectives.containsKey(rootLibrary)) { |
| 389 return _transitiveExternalDirectives[rootLibrary]; | 389 return _transitiveExternalDirectives[rootLibrary]; |
| 390 } | 390 } |
| 391 | 391 |
| 392 var results = new Set(); | 392 var results = new Set<Uri>(); |
| 393 var seen = new Set(); | 393 var seen = new Set<String>(); |
| 394 | 394 |
| 395 traverseLibrary(library) { | 395 traverseLibrary(String library) { |
| 396 library = p.normalize(library); | 396 library = p.normalize(library); |
| 397 if (seen.contains(library)) return true; | 397 if (seen.contains(library)) return true; |
| 398 seen.add(library); | 398 seen.add(library); |
| 399 | 399 |
| 400 var directives = _getDirectives(library); | 400 var directives = _getDirectives(library); |
| 401 if (directives == null) return false; | 401 if (directives == null) return false; |
| 402 | 402 |
| 403 for (var uri in directives) { | 403 for (var uri in directives) { |
| 404 var path; | 404 var path; |
| 405 if (uri.scheme == 'package') { | 405 if (uri.scheme == 'package') { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 return null; | 452 return null; |
| 453 } | 453 } |
| 454 | 454 |
| 455 _directives[libraryUri] = | 455 _directives[libraryUri] = |
| 456 parseImportsAndExports(readTextFile(library), name: library) | 456 parseImportsAndExports(readTextFile(library), name: library) |
| 457 .map((directive) => Uri.parse(directive.uri.stringValue)) | 457 .map((directive) => Uri.parse(directive.uri.stringValue)) |
| 458 .toSet(); | 458 .toSet(); |
| 459 return _directives[libraryUri]; | 459 return _directives[libraryUri]; |
| 460 } | 460 } |
| 461 } | 461 } |
| OLD | NEW |