graph

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Type  types.Type
	Elem  types.Type
	Key   types.Type
	Map   bool
	Items []CollectionItem
}

Collection describes a named slice or map binding.

type CollectionItem

type CollectionItem struct {
	Edge   Edge
	MapKey *model.Value
}

CollectionItem is one direct or imported multibinding contribution.

type Edge

type Edge struct {
	Node *Node
	Type types.Type
}

Edge connects a consumer input to one typed output of a dependency node.

type Export

type Export struct {
	Type     types.Type
	Position token.Pos
}

Export is one binding exposed to a parent module.

type Graph

type Graph struct {
	Root  *Module
	Nodes []*Node
}

Graph contains the module tree and all construction nodes.

func Build

func Build(
	fileSet *token.FileSet,
	root *model.Module,
) (*Graph, diagnostic.List)

Build normalizes a parsed injector module into a binding graph.

type Module

type Module struct {
	Name          string
	Model         *model.Module
	Parent        *Module
	Children      []*Module
	ScopeChildren []*Module
	// contains filtered or unexported fields
}

Module is one instantiated dependency boundary.

func (*Module) Exported

func (m *Module) Exported(key types.Type) bool

Exported reports whether key crosses this module's parent boundary.

func (*Module) Exports

func (m *Module) Exports() []Export

Exports returns bindings exposed by the module in source order.

type Node

type Node struct {
	ID           int
	Kind         NodeKind
	Position     token.Pos
	Module       *Module
	Callable     *model.Callable
	Value        *model.Value
	Outputs      []types.Type
	Inputs       []types.Type
	Dependencies []Edge
	Fallible     bool
	Managed      bool

	Collection *Collection
	Scope      *Scope
}

Node is one atomic construction operation.

type NodeKind

type NodeKind uint8

NodeKind identifies generated construction behavior.

const (
	NodeProvider NodeKind = iota + 1
	NodeValue
	NodeBind
	NodeDecorator
	NodeCollection
	NodeInput
	NodeScope
)

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver resolves typed entry points within module visibility rules.

func NewResolver

func NewResolver(fileSet *token.FileSet, graph *Graph) *Resolver

NewResolver constructs a resolver for graph.

func (*Resolver) AddInput

func (r *Resolver) AddInput(module *Module, input types.Type, position token.Pos) *Node

AddInput registers one injector or scope seed in module.

func (*Resolver) Diagnostics

func (r *Resolver) Diagnostics() diagnostic.List

Diagnostics returns errors found while resolving keys.

func (*Resolver) Resolve

func (r *Resolver) Resolve(module *Module, key types.Type) *Node

Resolve finds key from module and populates the reachable graph.

func (*Resolver) ValidateExports

func (r *Resolver) ValidateExports(root *Module)

ValidateExports checks every declared export below root, including unused ones. Scope seeds must be installed before calling it.

type Scope

type Scope struct {
	Factory types.Type
	Child   *Module
}

Scope describes a child module factory.

Jump to

Keyboard shortcuts

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