Documentation
¶
Overview ¶
Package graph provides an in-memory code knowledge graph with persistence.
Index ¶
- type Edge
- type EdgeKind
- type Graph
- func (g *Graph) AddEdge(e Edge) int
- func (g *Graph) AddNode(n Node) int
- func (g *Graph) AllEdges() []*Edge
- func (g *Graph) AllFiles() []string
- func (g *Graph) AllNodes() []*Node
- func (g *Graph) GetCallerCount(qualifiedName string) int
- func (g *Graph) GetEdgesBySource(qualifiedName string) []*Edge
- func (g *Graph) GetEdgesByTarget(qualifiedName string) []*Edge
- func (g *Graph) GetImpactRadius(changedQualifiedNames []string, maxDepth, maxNodes int) []*Node
- func (g *Graph) GetNode(qualifiedName string) (*Node, bool)
- func (g *Graph) GetNodesByFile(filePath string) []*Node
- func (g *Graph) GetNodesByKind(kinds ...NodeKind) []*Node
- func (g *Graph) GetStats() Stats
- func (g *Graph) HasTestCoverage(qualifiedName string) bool
- func (g *Graph) RemoveFileData(filePath string)
- func (g *Graph) Save(path string) error
- func (g *Graph) SearchNodes(query string, limit int) []*Node
- type Node
- type NodeKind
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Edge ¶
type Edge struct {
ID int `json:"id"`
Kind EdgeKind `json:"kind"`
SourceQualified string `json:"source_qualified"`
TargetQualified string `json:"target_qualified"`
FilePath string `json:"file_path"`
Line int `json:"line"`
}
Edge represents a relationship between two nodes.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a thread-safe in-memory code knowledge graph.
func (*Graph) GetCallerCount ¶
GetCallerCount returns the number of unique callers of a node.
func (*Graph) GetEdgesBySource ¶
GetEdgesBySource returns all edges originating from the given qualified name.
func (*Graph) GetEdgesByTarget ¶
GetEdgesByTarget returns all edges targeting the given qualified name.
func (*Graph) GetImpactRadius ¶
GetImpactRadius performs BFS from changed files to find affected nodes.
func (*Graph) GetNodesByFile ¶
GetNodesByFile returns all nodes in a given file.
func (*Graph) GetNodesByKind ¶
GetNodesByKind returns all nodes of the given kinds.
func (*Graph) HasTestCoverage ¶
HasTestCoverage checks if a node has any TESTED_BY edges. TESTED_BY edges: SourceQualified=function, TargetQualified=test_function
func (*Graph) RemoveFileData ¶
RemoveFileData removes all nodes and edges associated with a file.
type Node ¶
type Node struct {
ID int `json:"id"`
Kind NodeKind `json:"kind"`
Name string `json:"name"`
QualifiedName string `json:"qualified_name"`
FilePath string `json:"file_path"`
LineStart int `json:"line_start"`
LineEnd int `json:"line_end"`
Language string `json:"language"`
ParentName string `json:"parent_name,omitempty"`
Params string `json:"params,omitempty"`
ReturnType string `json:"return_type,omitempty"`
IsTest bool `json:"is_test"`
}
Node represents a code entity in the graph.
type Stats ¶
type Stats struct {
TotalNodes int `json:"total_nodes"`
TotalEdges int `json:"total_edges"`
NodesByKind map[string]int `json:"nodes_by_kind"`
EdgesByKind map[string]int `json:"edges_by_kind"`
Languages []string `json:"languages"`
FilesCount int `json:"files_count"`
}
Stats holds aggregate graph statistics.