parse

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGoModNotFound = errors.New("go mod not found")

Functions

This section is empty.

Types

type Adj added in v0.3.0

type Adj struct {
	Node *Node
	Func []string
}

type AstSchema

type AstSchema struct {
	ModulePath string
	Graph      *Graph
}

AstSchema is a simpler presentation of the ast of a project.

func Parse

func Parse(pathDir string, skipDirs []string) (AstSchema, error)

Parse parses the project located under pathDir and returns an AstSchema.

type Graph added in v0.3.0

type Graph struct {
	Nodes          []*Node            // A slice of pointers to all the nodes in the graph
	Adj            map[*Node][]*Adj   // An adjacency list mapping each node to its adjacent nodes
	NodeByName     map[string]*Node   // A hash map to store nodes by their names
	NodesByPackage map[string][]*Node // A hash map to store nodes by their packages
}

Graph represents the dependency graph.

func NewGraph added in v0.3.0

func NewGraph() *Graph

func (*Graph) AddEdge added in v0.3.0

func (g *Graph) AddEdge(from *Node, to *Adj)

AddEdge adds a directed edge between two nodes in the graph.

func (*Graph) AddNode added in v0.3.0

func (g *Graph) AddNode(node *Node)

AddNode adds a new Node to the graph.

func (*Graph) GetAdjacenciesSortedByName added in v0.3.0

func (g *Graph) GetAdjacenciesSortedByName(node *Node) []*Adj

GetAdjacenciesSortedByName returns the adjacencies sorted by the adjacent node names.

func (*Graph) GetAdjacency added in v0.3.0

func (g *Graph) GetAdjacency(node *Node) []*Adj

func (*Graph) GetLeafNodes added in v0.3.0

func (g *Graph) GetLeafNodes() []*Node

GetLeafNodes returns all the leaf nodes. A leaf node is a node without any inbound nodes.

func (*Graph) GetNodeByName added in v0.3.0

func (g *Graph) GetNodeByName(name string) *Node

GetNodeByName finds a node by its name in the graph.

func (*Graph) GetNodesSortedByName added in v0.3.0

func (g *Graph) GetNodesSortedByName() []*Node

GetNodesSortedByName returns all nodes sorted by node name.

func (*Graph) TopologicalSort added in v0.3.0

func (g *Graph) TopologicalSort() []*Node

TopologicalSort performs a topological sort on the graph.

type Node added in v0.3.0

type Node struct {
	Name            string // The fully qualified name of the struct, PackageName.StructName
	PackageName     string
	StructName      string
	Methods         []struct_decl.Method
	Doc             string
	External        bool
	InboundEdges    []*Node
	ActualNamedType *types.Named
	P               *packages.Package
	FilePath        string
}

Node represents a node of the dependency graph.

func (*Node) MergeAdditionalFields added in v0.3.0

func (n *Node) MergeAdditionalFields(other *Node)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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