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

Unified Diff: pkg/front_end/lib/dependency_grapher.dart

Issue 2572383004: Add preliminary packages file support to dependency_grapher. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/compiler_options.dart ('k') | pkg/front_end/test/dependency_grapher_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/dependency_grapher.dart
diff --git a/pkg/front_end/lib/dependency_grapher.dart b/pkg/front_end/lib/dependency_grapher.dart
index 7f9fbc8457f9e1f291072efe26990db51ecc5626..73541a1897e566db9db081bd8ec3a48309ce28e8 100644
--- a/pkg/front_end/lib/dependency_grapher.dart
+++ b/pkg/front_end/lib/dependency_grapher.dart
@@ -12,6 +12,7 @@ import 'package:front_end/file_system.dart';
import 'package:front_end/src/async_dependency_walker.dart';
import 'package:front_end/src/base/uri_resolver.dart';
import 'package:front_end/src/scanner/scanner.dart';
+import 'package:package_config/packages_file.dart' as package_config;
import 'compiler_options.dart';
@@ -22,7 +23,19 @@ import 'compiler_options.dart';
/// in the program.
Future<Graph> graphForProgram(
List<Uri> sources, CompilerOptions options) async {
- var packages = <String, Uri>{}; // TODO(paulberry): support packages
+ Map<String, Uri> packages;
+ if (options.packagesFilePath == null) {
+ throw new UnimplementedError(); // TODO(paulberry): search for .packages
Siggi Cherem (dart-lang) 2016/12/16 16:30:38 mmm... I recognize the value of having an abstract
Paul Berry 2016/12/16 17:59:07 Acknowledged.
+ } else if (options.packagesFilePath.isEmpty) {
+ packages = {};
+ } else {
+ var contents = await options.fileSystem
+ .entityForPath(options.packagesFilePath)
+ .readAsBytes();
+ var baseLocation =
+ options.fileSystem.context.toUri(options.packagesFilePath);
+ packages = package_config.parse(contents, baseLocation);
+ }
var sdkLibraries = <String, Uri>{}; // TODO(paulberry): support SDK libraries
var uriResolver =
new UriResolver(packages, sdkLibraries, options.fileSystem.context);
@@ -136,9 +149,13 @@ class _WalkerNode extends Node<_WalkerNode> {
Future<List<_WalkerNode>> computeDependencies() async {
var dependencies = <_WalkerNode>[];
// TODO(paulberry): add error recovery if the file can't be read.
- var contents = await walker.fileSystem
- .entityForPath(walker.uriResolver.resolve(uri))
- .readAsString();
+ var path = walker.uriResolver.resolve(uri);
+ if (path == null) {
+ // TODO(paulberry): If an error reporter was provided, report the error
+ // in the proper way and continue.
+ throw new StateError('Invalid URI: $uri');
+ }
+ var contents = await walker.fileSystem.entityForPath(path).readAsString();
var scanner = new _Scanner(contents);
var token = scanner.tokenize();
// TODO(paulberry): report errors.
« no previous file with comments | « pkg/front_end/lib/compiler_options.dart ('k') | pkg/front_end/test/dependency_grapher_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698