dep

package
v0.10.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package dep analyzes dependencies between values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Visit

func Visit(cfg *Config, c *adt.OpContext, n *adt.Vertex, f VisitFunc) error

Visit calls f for the dependencies of n as determined by the given configuration.

Types

type Config added in v0.6.0

type Config struct {
	// Dynamic enables evaluting dependencies Vertex Arcs, recursively
	Dynamic bool

	// Descend enables recursively descending into fields. This option is
	// implied by Dynamic.
	Descend bool

	// Cycles allows a Node to reported more than once. This includes the node
	// passed to Visit, which is otherwise never reported. This option can be
	// used to disable cycle checking. TODO: this is not yet implemented.
	AllowCycles bool

	// Rootless enables reporting nodes that do not have a path from the root.
	// This includes variables of comprehensions and fields of composite literal
	// values that are part of expressions, such as {out: v}.out.
	Rootless bool

	//  pkg indicates the main package for which the analyzer is configured,
	// which is used for reporting purposes.
	Pkg *adt.ImportReference
}

type Dependency

type Dependency struct {
	// Node is the referenced node.
	Node *adt.Vertex

	// Reference is the expression that referenced the node.
	Reference adt.Resolver
	// contains filtered or unexported fields
}

A Dependency is a reference and the node that reference resolves to.

func (*Dependency) Import

func (d *Dependency) Import() *adt.ImportReference

Import returns the import reference or nil if the reference was within the same package as the visited Vertex.

func (*Dependency) IsRoot

func (d *Dependency) IsRoot() bool

IsRoot reports whether the dependency is referenced by the root of the original Vertex passed to any of the Visit* functions, and not one of its descendent arcs. This always returns true for Visit().

func (*Dependency) Recurse added in v0.6.0

func (d *Dependency) Recurse()

Recurse visits the dependencies of d.Node, using the same visit function as the original.

type VisitFunc

type VisitFunc func(Dependency) error

VisitFunc is used for reporting dependencies.

Jump to

Keyboard shortcuts

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