Chromium Code Reviews| Index: pkg/front_end/lib/src/incremental/file_state.dart |
| diff --git a/pkg/front_end/lib/src/incremental/file_state.dart b/pkg/front_end/lib/src/incremental/file_state.dart |
| index 87c5323f1e696f2bbccfacc23315a045b880da79..d32384d8d7798c2be9c56aaad3aa64d25678909f 100644 |
| --- a/pkg/front_end/lib/src/incremental/file_state.dart |
| +++ b/pkg/front_end/lib/src/incremental/file_state.dart |
| @@ -399,6 +399,10 @@ class FileSystemState { |
| class LibraryCycle { |
| final List<FileState> libraries = <FileState>[]; |
| + /// [LibraryCycle]s that contain libraries directly import or export |
| + /// this [LibraryCycle]. |
| + final List<LibraryCycle> directUsers = <LibraryCycle>[]; |
| + |
| bool get _isForVm { |
| return libraries.any((l) => l.uri.toString().endsWith('dart:_vmservice')); |
| } |
| @@ -519,7 +523,7 @@ class _FileSystemViewEntry implements FileSystemEntity { |
| @override |
| Future<String> readAsString() async => _shouldNotBeQueried(); |
| - /// _FileSystemViewEntry is used by the incremental kernel generator to |
| + /// [_FileSystemViewEntry] is used by the incremental kernel generator to |
| /// provide Fasta with a consistent, race condition free view of the files |
| /// constituting the project. It should only need to be used for reading |
| /// file contents. |
| @@ -549,6 +553,7 @@ class _LibraryNode extends graph.Node<_LibraryNode> { |
| class _LibraryWalker extends graph.DependencyWalker<_LibraryNode> { |
| final nodesOfFiles = <FileState, _LibraryNode>{}; |
| final topologicallySortedCycles = <LibraryCycle>[]; |
| + final fileToCycleMap = <FileState, LibraryCycle>{}; |
| @override |
| void evaluate(_LibraryNode v) { |
| @@ -558,9 +563,30 @@ class _LibraryWalker extends graph.DependencyWalker<_LibraryNode> { |
| @override |
| void evaluateScc(List<_LibraryNode> scc) { |
| var cycle = new LibraryCycle(); |
| + |
| + // Build the set of cycles this cycles directly depends on. |
|
Paul Berry
2017/06/12 22:19:45
s/this cycles/this cycle/
|
| + var directDependencies = new Set<LibraryCycle>(); |
| + for (var node in scc) { |
| + var file = node.file; |
| + for (var importedLibrary in file.importedLibraries) { |
| + var importedCycle = fileToCycleMap[importedLibrary]; |
| + if (importedCycle != null) directDependencies.add(importedCycle); |
| + } |
| + for (var exportedLibrary in file.exportedLibraries) { |
| + var exportedCycle = fileToCycleMap[exportedLibrary]; |
| + if (exportedCycle != null) directDependencies.add(exportedCycle); |
| + } |
| + } |
| + |
| + // Register this cycle as a direct user of the direct dependencies. |
| + for (var directDependency in directDependencies) { |
| + directDependency.directUsers.add(cycle); |
| + } |
| + |
| for (var node in scc) { |
| node.isEvaluated = true; |
| cycle.libraries.add(node.file); |
| + fileToCycleMap[node.file] = cycle; |
| } |
| topologicallySortedCycles.add(cycle); |
| } |