graph

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package graph provides dependency graph analysis for Go symbols.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DependencyGraph

type DependencyGraph struct {
	Symbols  map[string]*Symbol             // ID -> Symbol.
	FileSyms map[string][]string            // File -> defined symbol IDs.
	OutEdges map[string]map[string]struct{} // Symbol -> symbols it depends on.
	InEdges  map[string]map[string]struct{} // Symbol -> symbols that depend on it.
}

DependencyGraph represents the dependency relationships between symbols.

func NewDependencyGraph

func NewDependencyGraph() *DependencyGraph

NewDependencyGraph creates a new empty dependency graph.

func (*DependencyGraph) AddDependency

func (g *DependencyGraph) AddDependency(from, to string)

AddDependency adds a dependency edge from one symbol to another.

func (*DependencyGraph) AnalyzePackage

func (g *DependencyGraph) AnalyzePackage(pkg *packages.Package)

AnalyzePackage analyzes a package and adds its symbols and dependencies to the graph. Packages with nil TypesInfo (e.g. those with parse/type errors) are skipped.

func (*DependencyGraph) TransitiveDependents

func (g *DependencyGraph) TransitiveDependents(targetID string) []string

TransitiveDependents returns all symbols that transitively depend on the given symbol.

func (*DependencyGraph) TransitiveDeps

func (g *DependencyGraph) TransitiveDeps(startID string) []string

TransitiveDeps returns all symbols that the given symbol transitively depends on.

type Symbol

type Symbol struct {
	ID      string         // "pkg/path.SymbolName".
	Name    string         // Symbol name.
	Package string         // Package path.
	Kind    string         // "func", "type", "var", "const".
	File    string         // Defining file path.
	Pos     token.Position // Source position.
}

Symbol represents a symbol in the dependency graph.

Jump to

Keyboard shortcuts

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