feat(go-analyzer): add data model types
This commit is contained in:
77
tools/go-analyzer/types.go
Normal file
77
tools/go-analyzer/types.go
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
// AnalysisResult holds all extracted data from Go source analysis.
|
||||||
|
type AnalysisResult struct {
|
||||||
|
Modules []Module
|
||||||
|
Dependencies []Dependency
|
||||||
|
Imports []ImportInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalFeatures returns the count of all features across all modules.
|
||||||
|
func (r *AnalysisResult) TotalFeatures() int {
|
||||||
|
count := 0
|
||||||
|
for _, m := range r.Modules {
|
||||||
|
count += len(m.Features)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalTests returns the count of all tests across all modules.
|
||||||
|
func (r *AnalysisResult) TotalTests() int {
|
||||||
|
count := 0
|
||||||
|
for _, m := range r.Modules {
|
||||||
|
count += len(m.Tests)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module represents a logical grouping of Go source files.
|
||||||
|
type Module struct {
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
GoPackage string
|
||||||
|
GoFile string // primary file or directory
|
||||||
|
GoLineCount int
|
||||||
|
Features []Feature
|
||||||
|
Tests []TestFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feature represents a function or method extracted from Go source.
|
||||||
|
type Feature struct {
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
GoFile string
|
||||||
|
GoClass string // receiver type, empty for package-level functions
|
||||||
|
GoMethod string
|
||||||
|
GoLineNumber int
|
||||||
|
GoLineCount int
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestFunc represents a test function extracted from Go source.
|
||||||
|
type TestFunc struct {
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
GoFile string
|
||||||
|
GoClass string
|
||||||
|
GoMethod string
|
||||||
|
GoLineNumber int
|
||||||
|
GoLineCount int
|
||||||
|
// FeatureName links this test to a feature by naming convention
|
||||||
|
FeatureName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dependency represents a call relationship between two items.
|
||||||
|
type Dependency struct {
|
||||||
|
SourceModule string
|
||||||
|
SourceFeature string // empty for module-level deps
|
||||||
|
TargetModule string
|
||||||
|
TargetFeature string // empty for module-level deps
|
||||||
|
DependencyKind string // "calls"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImportInfo represents a Go import path found in source files.
|
||||||
|
type ImportInfo struct {
|
||||||
|
ImportPath string
|
||||||
|
IsStdlib bool
|
||||||
|
UsedInFiles []string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user