Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 | 236 |
| 237 // Create graph nodes for packages. | 237 // Create graph nodes for packages. |
| 238 List<_LinkedNode> nodes = <_LinkedNode>[]; | 238 List<_LinkedNode> nodes = <_LinkedNode>[]; |
| 239 Map<String, _LinkedNode> packageToNode = <String, _LinkedNode>{}; | 239 Map<String, _LinkedNode> packageToNode = <String, _LinkedNode>{}; |
| 240 unlinkedBundles.forEach((package, unlinked) { | 240 unlinkedBundles.forEach((package, unlinked) { |
| 241 _LinkedNode node = new _LinkedNode(package, unlinked, packageToNode); | 241 _LinkedNode node = new _LinkedNode(package, unlinked, packageToNode); |
| 242 nodes.add(node); | 242 nodes.add(node); |
| 243 packageToNode[package.name] = node; | 243 packageToNode[package.name] = node; |
| 244 }); | 244 }); |
| 245 | 245 |
| 246 // Fill the store with unlinked bundles. | 246 // Fill the store with the linked SDK and unlinked package bundles. |
| 247 SummaryDataStore store = new SummaryDataStore(const <String>[]); | 247 SummaryDataStore store = new SummaryDataStore(const <String>[]); |
| 248 store.addBundle(null, sdkBundle); | 248 store.addBundle(null, sdkBundle); |
| 249 { | |
| 250 PackageBundle extension = computeSdkExtension(context, sdkBundle); | |
| 251 if (extension != null) { | |
| 252 store.addBundle(null, extension); | |
| 253 } | |
| 254 } | |
| 249 for (PackageBundle unlinked in unlinkedBundles.values) { | 255 for (PackageBundle unlinked in unlinkedBundles.values) { |
| 250 store.addBundle(null, unlinked); | 256 store.addBundle(null, unlinked); |
| 251 } | 257 } |
| 252 | 258 |
| 253 // Link each package node. | 259 // Link each package node. |
| 254 for (_LinkedNode node in nodes) { | 260 for (_LinkedNode node in nodes) { |
| 255 if (!node.isEvaluated) { | 261 if (!node.isEvaluated) { |
| 256 bool strong = context.analysisOptions.strongMode; | 262 bool strong = context.analysisOptions.strongMode; |
| 257 new _LinkedWalker(store, strong).walk(node); | 263 new _LinkedWalker(store, strong).walk(node); |
| 258 } | 264 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 @override | 528 @override |
| 523 List<_LinkedNode> computeDependencies() { | 529 List<_LinkedNode> computeDependencies() { |
| 524 Set<_LinkedNode> dependencies = new Set<_LinkedNode>(); | 530 Set<_LinkedNode> dependencies = new Set<_LinkedNode>(); |
| 525 for (UnlinkedUnit unit in unlinked.unlinkedUnits) { | 531 for (UnlinkedUnit unit in unlinked.unlinkedUnits) { |
| 526 for (UnlinkedImport import in unit.imports) { | 532 for (UnlinkedImport import in unit.imports) { |
| 527 String uriStr = import.isImplicit ? 'dart:core' : import.uri; | 533 String uriStr = import.isImplicit ? 'dart:core' : import.uri; |
| 528 Uri uri = FastUri.parse(uriStr); | 534 Uri uri = FastUri.parse(uriStr); |
| 529 if (!uri.hasScheme) { | 535 if (!uri.hasScheme) { |
| 530 // A relative path in this package, skip it. | 536 // A relative path in this package, skip it. |
| 531 } else if (uri.scheme == 'dart') { | 537 } else if (uri.scheme == 'dart') { |
| 532 // TODO(scheglov) link _sdkext bundles. | 538 // Dependency on the SDK is implicit and always added. |
| 539 // The SDK linked bundle is precomputed before linking packages. | |
|
Paul Berry
2016/08/11 20:47:17
(As discussed in person) I think we still need to
| |
| 533 } else if (uriStr.startsWith('package:')) { | 540 } else if (uriStr.startsWith('package:')) { |
| 534 String package = PubSummaryManager.getPackageName(uriStr); | 541 String package = PubSummaryManager.getPackageName(uriStr); |
| 535 _LinkedNode packageNode = packageToNode[package]; | 542 _LinkedNode packageNode = packageToNode[package]; |
| 536 if (packageNode == null) { | 543 if (packageNode == null) { |
| 537 failed = true; | 544 failed = true; |
| 538 return const <_LinkedNode>[]; | 545 return const <_LinkedNode>[]; |
| 539 } | 546 } |
| 540 dependencies.add(packageNode); | 547 dependencies.add(packageNode); |
| 541 } else { | 548 } else { |
| 542 failed = true; | 549 failed = true; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 } | 607 } |
| 601 }); | 608 }); |
| 602 node.linkedBuilder = assembler.assemble(); | 609 node.linkedBuilder = assembler.assemble(); |
| 603 store.addBundle(null, node.linkedBuilder); | 610 store.addBundle(null, node.linkedBuilder); |
| 604 } | 611 } |
| 605 } else { | 612 } else { |
| 606 scc.forEach((node) => node.failed = true); | 613 scc.forEach((node) => node.failed = true); |
| 607 } | 614 } |
| 608 } | 615 } |
| 609 } | 616 } |
| OLD | NEW |