cycles

package
v2.936.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cycle

type Cycle map[*ast.TypeDef]bool

Cycle represents a strongly connected component (SCC) as a set of TypeDef pointers

func (Cycle) ToMermaid

func (c Cycle) ToMermaid() string

ToMermaid makes it easy to visualize the cycle, only used for debugging

type CycleDetector

type CycleDetector struct {
	// Cycles found in the AST
	Cycles []Cycle
	// contains filtered or unexported fields
}

func New

func New() *CycleDetector

CycleDetector detects cycles otherwise known as strongly connected components (SCCs) using Tarjan's algorithm Cycles differ from SCCs in one subtle way: a single node is considered an SCC even if it's not self-referential we discard these trivial SCCs are they are not cycles.

func (*CycleDetector) AreCircular

func (c *CycleDetector) AreCircular(t1 *ast.TypeDef, t2 *ast.TypeDef) bool

AreCircular checks if two TypeDefs are part of the same cycle.

func (*CycleDetector) DetectCycles

func (c *CycleDetector) DetectCycles(t ast.TypeDefs) []Cycle

func (*CycleDetector) IsPartOfCycle

func (c *CycleDetector) IsPartOfCycle(t *ast.TypeDef) bool

IsPartOfCycle checks if a TypeDef is part of a cycle

func (*CycleDetector) Traverse

func (c *CycleDetector) Traverse(t *ast.TypeDef)

Jump to

Keyboard shortcuts

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