ImportGraph class

The project's own import graph, built from the directives the sorter already reads on every run.

Nodes are project files, named by their path from the project root with / separators (lib/src/foo.dart). Edges point from a file to the project files it depends on — import, export and part all count, since all three create a reason for a file to exist.

dart: URIs and packages outside the project are not nodes: nothing here can say anything useful about them.

Constructors

ImportGraph(Map<String, Set<String>> edges, {Map<String, String> packages = const {'' : ''}})
const
ImportGraph.build(Map<String, List<String>> directivesByFile, String packageName, {Map<String, String> packages = const {}})
Builds a graph from directivesByFile, a map of project-relative file path to the raw URIs that file declares.
factory

Properties

edges Map<String, Set<String>>
File -> the project files it depends on.
final
hashCode int
The hash code for this object.
no setterinherited
packages Map<String, String>
Package directory -> package name, for every package the graph spans. The root package lives at ''.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cycles() List<List<String>>
Every group of files that depend on each other, directly or through others — the strongly connected components with more than one member. Each group is sorted; groups come largest first.
cycleWalk(List<String> group) List<String>
A shortest closed walk through group starting at its first member, following only edges that exist. The last element points back to the first.
isLibraryFile(String file) bool
Whether file sits under the lib/ of any package in packages.
libraryRoot(String file) String?
The lib/ directory file belongs to, as a prefix (lib/, packages/core/lib/), or null for a file outside every one.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
unreachable({required Set<String> roots}) List<String>
Library files that no entry point can reach.
unreferenced({required Set<String> roots}) List<String>
Library files that nothing in the project refers to: in-degree zero over edges, with roots exempt.

Operators

operator ==(Object other) bool
The equality operator.
inherited