| Index: pkg/front_end/lib/src/dependency_grapher_impl.dart
|
| diff --git a/pkg/front_end/lib/dependency_grapher.dart b/pkg/front_end/lib/src/dependency_grapher_impl.dart
|
| similarity index 71%
|
| copy from pkg/front_end/lib/dependency_grapher.dart
|
| copy to pkg/front_end/lib/src/dependency_grapher_impl.dart
|
| index fcb9a210b426230a863a09de04bfae51cf32c00c..5dbe12d998d7f96c0bdbb839d03b8abeab5d07e7 100644
|
| --- a/pkg/front_end/lib/dependency_grapher.dart
|
| +++ b/pkg/front_end/lib/src/dependency_grapher_impl.dart
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| @@ -8,68 +8,30 @@ import 'package:analyzer/dart/ast/ast.dart';
|
| import 'package:analyzer/error/listener.dart';
|
| import 'package:analyzer/src/dart/scanner/reader.dart';
|
| import 'package:analyzer/src/generated/parser.dart';
|
| +import 'package:front_end/dependency_grapher.dart';
|
| import 'package:front_end/file_system.dart';
|
| import 'package:front_end/src/async_dependency_walker.dart';
|
| import 'package:front_end/src/base/processed_options.dart';
|
| import 'package:front_end/src/base/uri_resolver.dart';
|
| import 'package:front_end/src/scanner/scanner.dart';
|
|
|
| -import 'compiler_options.dart';
|
| -
|
| /// Generates a representation of the dependency graph of a program.
|
| ///
|
| /// Given the Uri of one or more files, this function follows `import`,
|
| /// `export`, and `part` declarations to discover a graph of all files involved
|
| /// in the program.
|
| +///
|
| +/// This is intended for internal use by the front end. Clients should use
|
| +/// package:front_end/dependency_grapher.dart.
|
| Future<Graph> graphForProgram(
|
| - List<Uri> sources, CompilerOptions options) async {
|
| - var processedOptions = new ProcessedOptions(options);
|
| - var uriResolver = await processedOptions.getUriResolver();
|
| - var walker = new _Walker(processedOptions.fileSystem, uriResolver, processedOptions.compileSdk);
|
| + List<Uri> sources, ProcessedOptions options) async {
|
| + var uriResolver = await options.getUriResolver();
|
| + var walker = new _Walker(options.fileSystem, uriResolver, options.compileSdk);
|
| var startingPoint = new _StartingPoint(walker, sources);
|
| await walker.walk(startingPoint);
|
| return walker.graph;
|
| }
|
|
|
| -/// A representation of the dependency graph of a program.
|
| -///
|
| -/// Not intended to be extended, implemented, or mixed in by clients.
|
| -class Graph {
|
| - /// A list of all library cycles in the program, in topologically sorted order
|
| - /// (each cycle only depends on libraries in the cycles that precede it).
|
| - final topologicallySortedCycles = <LibraryCycleNode>[];
|
| -
|
| - Graph._();
|
| -}
|
| -
|
| -/// A representation of a single library cycle in the dependency graph of a
|
| -/// program.
|
| -///
|
| -/// Not intended to be extended, implemented, or mixed in by clients.
|
| -class LibraryCycleNode {
|
| - /// A map of all the libraries in the cycle, keyed by the URI of their
|
| - /// defining compilation unit.
|
| - final libraries = <Uri, LibraryNode>{};
|
| -
|
| - LibraryCycleNode._();
|
| -}
|
| -
|
| -/// A representation of a single library in the dependency graph of a program.
|
| -///
|
| -/// Not intended to be extended, implemented, or mixed in by clients.
|
| -class LibraryNode {
|
| - /// The URI of this library's defining compilation unit.
|
| - final Uri uri;
|
| -
|
| - /// A list of the URIs of all of this library's "part" files.
|
| - final parts = <Uri>[];
|
| -
|
| - /// A list of all the other libraries this library directly depends on.
|
| - final dependencies = <LibraryNode>[];
|
| -
|
| - LibraryNode._(this.uri);
|
| -}
|
| -
|
| class _Scanner extends Scanner {
|
| _Scanner(String contents) : super(new CharSequenceReader(contents)) {
|
| preserveComments = false;
|
| @@ -95,7 +57,7 @@ class _Walker extends AsyncDependencyWalker<_WalkerNode> {
|
| final FileSystem fileSystem;
|
| final UriResolver uriResolver;
|
| final _nodesByUri = <Uri, _WalkerNode>{};
|
| - final graph = new Graph._();
|
| + final graph = new Graph();
|
| final bool compileSdk;
|
|
|
| _Walker(this.fileSystem, this.uriResolver, this.compileSdk);
|
| @@ -108,7 +70,7 @@ class _Walker extends AsyncDependencyWalker<_WalkerNode> {
|
|
|
| @override
|
| Future<Null> evaluateScc(List<_WalkerNode> scc) {
|
| - var cycle = new LibraryCycleNode._();
|
| + var cycle = new LibraryCycleNode();
|
| for (var walkerNode in scc) {
|
| cycle.libraries[walkerNode.uri] = walkerNode.library;
|
| }
|
| @@ -131,7 +93,7 @@ class _WalkerNode extends Node<_WalkerNode> {
|
|
|
| _WalkerNode(this.walker, Uri uri)
|
| : uri = uri,
|
| - library = new LibraryNode._(uri);
|
| + library = new LibraryNode(uri);
|
|
|
| @override
|
| Future<List<_WalkerNode>> computeDependencies() async {
|
|
|