depgraph

package
v0.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjacencyList

func AdjacencyList(g DependencyGraph) (map[string][]string, error)

AdjacencyList returns a plain adjacency list for the given graph.

func ContainsNode

func ContainsNode(g DependencyGraph, node string) bool

ContainsNode reports whether node exists in the graph.

func DependenciesOf

func DependenciesOf(g DependencyGraph, node string) ([]string, bool, error)

DependenciesOf returns outgoing dependencies for a node.

Types

type DependencyGraph

type DependencyGraph = graphlib.Graph[string, string]

DependencyGraph is the shared graph type used across the codebase.

func BuildDependencyGraph

func BuildDependencyGraph(filePaths []string, contentReader vcs.ContentReader) (DependencyGraph, error)

BuildDependencyGraph analyzes a list of files and builds a dependency graph containing only project imports (excluding package:/dart: imports for Dart, and standard library/external imports for Go). Only dependencies that are in the supplied file list are included in the graph. The contentReader function is used to read file contents (from filesystem, git commit, etc.)

func BuildDependencyGraphWithResolver

func BuildDependencyGraphWithResolver(
	filePaths []string,
	dependencyResolver DependencyResolver,
) (DependencyGraph, error)

BuildDependencyGraphWithResolver builds a graph using the provided DependencyResolver implementation.

func FindPathNodes

func FindPathNodes(graph DependencyGraph, targetFiles []string) DependencyGraph

FindPathNodes returns all nodes on any path between specified files. Treats the graph bidirectionally (paths from A to B OR from B to A). A node X is included if it lies on any directed path between any pair of target files. If a file isn't in the graph, it's skipped.

func MustDependencyGraph

func MustDependencyGraph(adjacency map[string][]string) DependencyGraph

MustDependencyGraph builds a graph from adjacency data and panics on errors. Intended for tests.

func NewDependencyGraph

func NewDependencyGraph() DependencyGraph

NewDependencyGraph creates an empty directed dependency graph.

func NewDependencyGraphFromAdjacency

func NewDependencyGraphFromAdjacency(adjacency map[string][]string) (DependencyGraph, error)

NewDependencyGraphFromAdjacency builds a graph from adjacency data.

type DependencyResolver

type DependencyResolver interface {
	SupportsFileExtension(ext string) bool
	ResolveProjectImports(absPath, filePath, ext string) ([]string, error)
	FinalizeGraph(graph DependencyGraph) error
}

DependencyResolver resolves project imports per file and can finalize graph-wide dependencies.

func NewDefaultDependencyResolver

func NewDefaultDependencyResolver(ctx *dependencyGraphContext, contentReader vcs.ContentReader) DependencyResolver

NewDefaultDependencyResolver creates the built-in language-aware dependency resolver.

type EdgeMetadata

type EdgeMetadata struct {
	InCycle bool
}

EdgeMetadata holds metadata for a graph edge.

type FileCycle

type FileCycle struct {
	Path []string
}

FileCycle describes a representative cycle path for a cyclic SCC.

type FileDependencyGraph

type FileDependencyGraph struct {
	Graph DependencyGraph
	Meta  FileGraphMetadata
}

FileDependencyGraph wraps a dependency graph with file-level metadata.

func NewFileDependencyGraph

func NewFileDependencyGraph(g DependencyGraph, fileStats map[string]vcs.FileStats, contentReader vcs.ContentReader) (FileDependencyGraph, error)

NewFileDependencyGraph creates a file-annotated graph from a dependency graph, optional file stats, and an optional content reader used for richer test detection.

func (*FileDependencyGraph) AnnotateRustPhantomsShow added in v0.22.0

func (g *FileDependencyGraph) AnnotateRustPhantomsShow(contentReader vcs.ContentReader)

AnnotateRustPhantomsShow populates PhantomMetadata for every .rs file in the graph whose contents include a `#[cfg(test)]` region. Intended for `clarity show` (point-in-time) usage where the presence of an in-file test region is enough to render the phantom node.

func (*FileDependencyGraph) AnnotateRustPhantomsWatch added in v0.22.0

func (g *FileDependencyGraph) AnnotateRustPhantomsWatch(
	diffs map[string]vcs.FileDiff,
	oldContent vcs.ContentReader,
	newContent vcs.ContentReader,
)

AnnotateRustPhantomsWatch populates PhantomMetadata for .rs files in the graph using watch-mode rules: the phantom is added only when the file's test region has additions or deletions in the supplied diff. The file's own Stats are also rewritten to reflect the prod-side split.

type FileEdge

type FileEdge struct {
	From string
	To   string
}

FileEdge identifies a directed edge between two files.

type FileGraphMetadata

type FileGraphMetadata struct {
	Files  map[string]FileMetadata
	Edges  map[FileEdge]EdgeMetadata
	Cycles []FileCycle
}

FileGraphMetadata contains metadata keyed by file and edge.

type FileMetadata

type FileMetadata struct {
	Stats     *vcs.FileStats
	IsTest    bool
	IsPruned  bool
	Extension string
	Phantom   *PhantomMetadata
}

FileMetadata holds metadata for a single file node.

type PhantomMetadata added in v0.22.0

type PhantomMetadata struct {
	Kind        string
	Stats       *vcs.FileStats
	ProdChanged bool
}

PhantomMetadata describes a sibling "phantom" node attached to a file to represent in-file test code as a distinct visual node. Kind identifies the language-specific source of the phantom (e.g. "rust-test"). Stats carries any per-line attribution for watch mode; nil in show mode. ProdChanged is true when the prod side of the file also has changes (watch mode only).

Directories

Path Synopsis
languages
c
cpp
zig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL