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

coupling(int depth) → List<Coupling>
Every pair of features at depth joined by at least one edge, with the number of imports from one into the other — heaviest first.
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.
fanIn() → Map<String, int>
How many project files depend on each file — its fan-in. Every node is a key, so a file nothing imports reads 0.
fanOut() → Map<String, int>
How many project files each file depends on — its fan-out.
featureOf(String file, int depth) → String?
The feature file belongs to: its directory under lib/, cut to depth folders — or null for a file outside every lib/.
features(int depth) → List<FeatureMetrics>
Every feature at depth, with its size and how it couples to the rest, sorted by name. Only files under a lib/ take part, and only edges that cross from one feature into another count.
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