Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions sourcecode-parser/graph/callgraph/attribute_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,16 @@ package callgraph
import (
"sync"

"github.com/shivasurya/code-pathfinder/sourcecode-parser/graph"
"github.com/shivasurya/code-pathfinder/sourcecode-parser/graph/callgraph/core"
)

// ClassAttribute represents a single attribute of a class.
type ClassAttribute struct {
Name string // Attribute name (e.g., "value", "user")
Type *TypeInfo // Inferred type of the attribute
AssignedIn string // Method where assigned (e.g., "__init__", "setup")
Location *graph.SourceLocation
Confidence float64 // Confidence in type inference (0.0-1.0)
}
// Deprecated: Use core.ClassAttribute instead.
// This alias will be removed in a future version.
type ClassAttribute = core.ClassAttribute

// ClassAttributes holds all attributes for a single class.
type ClassAttributes struct {
ClassFQN string // Fully qualified class name (e.g., "myapp.models.User")
Attributes map[string]*ClassAttribute // Map from attribute name to attribute info
Methods []string // List of method FQNs in this class
FilePath string // Source file path where class is defined
}
// Deprecated: Use core.ClassAttributes instead.
// This alias will be removed in a future version.
type ClassAttributes = core.ClassAttributes

// AttributeRegistry is the global registry of class attributes
// It provides thread-safe access to class attribute information.
Expand Down
30 changes: 30 additions & 0 deletions sourcecode-parser/graph/callgraph/core/attribute_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package core

import (
"github.com/shivasurya/code-pathfinder/sourcecode-parser/graph"
)

// TypeInfo represents inferred type information for a variable or expression.
// It tracks the fully qualified type name, confidence level, and how the type was inferred.
type TypeInfo struct {
TypeFQN string // Fully qualified type name (e.g., "builtins.str", "myapp.models.User")
Confidence float32 // Confidence level from 0.0 to 1.0 (1.0 = certain, 0.5 = heuristic, 0.0 = unknown)
Source string // How the type was inferred (e.g., "literal", "assignment", "annotation")
}

// ClassAttribute represents a single attribute of a class.
type ClassAttribute struct {
Name string // Attribute name (e.g., "value", "user")
Type *TypeInfo // Inferred type of the attribute
AssignedIn string // Method where assigned (e.g., "__init__", "setup")
Location *graph.SourceLocation // Source location of the attribute
Confidence float64 // Confidence in type inference (0.0-1.0)
}

// ClassAttributes holds all attributes for a single class.
type ClassAttributes struct {
ClassFQN string // Fully qualified class name (e.g., "myapp.models.User")
Attributes map[string]*ClassAttribute // Map from attribute name to attribute info
Methods []string // List of method FQNs in this class
FilePath string // Source file path where class is defined
}
24 changes: 24 additions & 0 deletions sourcecode-parser/graph/callgraph/core/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Package core provides foundational type definitions for the callgraph analyzer.
//
// This package contains pure data structures with minimal dependencies that form
// the contract for all other callgraph packages. Types in this package should:
//
// - Have zero circular dependencies
// - Contain minimal business logic
// - Be stable and rarely change
//
// # Core Types
//
// CallGraph represents the complete call graph with edges between functions.
//
// Statement represents individual program statements for def-use analysis.
//
// TaintSummary stores results of taint analysis for a function.
//
// # Usage
//
// import "github.com/shivasurya/code-pathfinder/sourcecode-parser/graph/callgraph/core"
//
// cg := core.NewCallGraph()
// cg.AddEdge("main.foo", "main.bar")
package core
Loading
Loading