depgraph

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: AGPL-3.0 Imports: 20 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.

func IsSupportedLanguageExtension

func IsSupportedLanguageExtension(ext string) bool

IsSupportedLanguageExtension reports whether Clarity can analyze files with the extension.

func IsTestFile

func IsTestFile(filePath string, contentReader vcs.ContentReader) bool

IsTestFile reports whether a file path should be treated as a test file. Detection is delegated to language-specific implementations, optionally using file content.

func SupportedLanguageExtensions

func SupportedLanguageExtensions() []string

SupportedLanguageExtensions returns all supported language extensions in sorted order.

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.

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
	Extension string
}

FileMetadata holds metadata for a single file node.

type LanguageSupport

type LanguageSupport struct {
	Name       string
	Extensions []string
	Maturity   langsupport.MaturityLevel
}

LanguageSupport describes one supported programming language and the file extensions that map to it.

func SupportedLanguages

func SupportedLanguages() []LanguageSupport

SupportedLanguages returns a copy of all supported languages and their extensions.

Directories

Path Synopsis
c

Jump to

Keyboard shortcuts

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