Documentation
¶
Index ¶
- type Database
- func (db *Database) Close() error
- func (db *Database) DeleteDependenciesByFile(fileID int64) error
- func (db *Database) DeleteEntitiesByFile(fileID int64) error
- func (db *Database) GetAllDependencies() ([]*Dependency, error)
- func (db *Database) GetAllEntities() ([]*Entity, error)
- func (db *Database) GetAllRelations() ([]*EntityRelation, error)
- func (db *Database) GetCallGraph(entityID int64, depth int) (map[string]interface{}, error)
- func (db *Database) GetDB() *gorm.DB
- func (db *Database) GetDependencies(fileID int64) ([]*Dependency, error)
- func (db *Database) GetDependencyCount() (int64, error)
- func (db *Database) GetDependencyGraph(filePath string) (map[string]interface{}, error)
- func (db *Database) GetEntitiesByFile(fileID int64) ([]*Entity, error)
- func (db *Database) GetEntityByID(id int64) (*Entity, error)
- func (db *Database) GetEntityByName(name string) ([]*Entity, error)
- func (db *Database) GetEntityCount() (int64, error)
- func (db *Database) GetEntityRelations(entityID int64, relationType string) ([]*EntityRelation, error)
- func (db *Database) GetFileByID(id int64) (*File, error)
- func (db *Database) GetFileByPath(path string) (*File, error)
- func (db *Database) GetFileCount() (int64, error)
- func (db *Database) GetFiles() ([]*File, error)
- func (db *Database) GetRelationCount() (int64, error)
- func (db *Database) InsertDependency(sourceFileID int64, targetPath, depType string, lineNumber int) (int64, error)
- func (db *Database) InsertEntity(fileID int64, name, entityType, kind, signature string, startLine, endLine int, ...) (int64, error)
- func (db *Database) InsertEntityRelation(sourceID, targetID int64, relationType string, lineNumber int, context string) (int64, error)
- func (db *Database) InsertFile(path, language, hash string) (int64, error)
- func (db *Database) WithTx(tx *gorm.DB) *Database
- type Dependency
- type Entity
- type EntityRelation
- type File
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func Open ¶
Open creates or opens a SQLite database at the specified path using GORM. verbose enables SQL query logging.
func (*Database) DeleteDependenciesByFile ¶
DeleteDependenciesByFile removes all dependency records for the given file.
func (*Database) DeleteEntitiesByFile ¶
DeleteEntitiesByFile removes all entities for the given file. The CASCADE constraint on EntityRelation automatically removes relation rows.
func (*Database) GetAllDependencies ¶
func (db *Database) GetAllDependencies() ([]*Dependency, error)
func (*Database) GetAllEntities ¶
func (*Database) GetAllRelations ¶
func (db *Database) GetAllRelations() ([]*EntityRelation, error)
func (*Database) GetCallGraph ¶
func (*Database) GetDependencies ¶
func (db *Database) GetDependencies(fileID int64) ([]*Dependency, error)
func (*Database) GetDependencyCount ¶
func (*Database) GetDependencyGraph ¶
func (*Database) GetEntitiesByFile ¶
func (*Database) GetEntityByName ¶
func (*Database) GetEntityCount ¶
func (*Database) GetEntityRelations ¶
func (db *Database) GetEntityRelations(entityID int64, relationType string) ([]*EntityRelation, error)
func (*Database) GetFileCount ¶
func (*Database) GetRelationCount ¶
func (*Database) InsertDependency ¶
func (db *Database) InsertDependency(sourceFileID int64, targetPath, depType string, lineNumber int) (int64, error)
InsertDependency upserts a dependency record.
func (*Database) InsertEntity ¶
func (db *Database) InsertEntity(fileID int64, name, entityType, kind, signature string, startLine, endLine int, docs, parent, visibility, scope, language string) (int64, error)
InsertEntity inserts a new entity, or returns the existing ID if an entity with the same file+name+type+start_line already exists.
func (*Database) InsertEntityRelation ¶
func (db *Database) InsertEntityRelation(sourceID, targetID int64, relationType string, lineNumber int, context string) (int64, error)
InsertEntityRelation upserts a relation row.
func (*Database) InsertFile ¶
InsertFile upserts a file record. If the path already exists the hash and language are updated and the existing ID is returned.
type Dependency ¶
type Dependency struct {
ID int64 `gorm:"primaryKey"`
SourceFileID int64 `gorm:"index;not null"`
TargetPath string `gorm:"not null"` // Import path as written in code
ImportType string // import, require, from, include
LineNumber int
Resolved string // Resolved module/file path if determined
IsLocal bool // True if local module/relative import
SourceFile *File `gorm:"foreignKey:SourceFileID"`
}
Dependency represents a file dependency (import/require)
func (Dependency) TableName ¶
func (Dependency) TableName() string
type Entity ¶
type Entity struct {
ID int64 `gorm:"primaryKey"`
FileID int64 `gorm:"index;not null"`
Name string `gorm:"index;not null"`
Type string `gorm:"index;not null"` // function, class, interface, type, method, etc.
Kind string // specific kind: async_function, arrow_function, method, etc.
Signature string
StartLine int
EndLine int
ColumnStart int
ColumnEnd int
Documentation string
// Multi-language support fields
Parent string // Parent entity name for nested entities (e.g., "ClassName" for methods)
Visibility string `gorm:"index"` // public, private, protected, internal
Scope string // file, class, module, global, local
Language string `gorm:"index"` // go, python, javascript, typescript, java
Attributes string // JSON: {decorators: [], typeParams: [], modifiers: [], etc.}
// Relationships
File *File `gorm:"foreignKey:FileID"`
SourceRelations []EntityRelation `gorm:"foreignKey:SourceEntityID;constraint:OnDelete:CASCADE"`
TargetRelations []EntityRelation `gorm:"foreignKey:TargetEntityID;constraint:OnDelete:CASCADE"`
}
Entity represents a code entity (function, class, type, etc.)
type EntityRelation ¶
type EntityRelation struct {
ID int64 `gorm:"primaryKey"`
SourceEntityID int64 `gorm:"index;not null"`
TargetEntityID int64 `gorm:"index;not null"`
RelationType string `gorm:"index;not null"`
LineNumber int
Context string
SourceEntity *Entity `gorm:"foreignKey:SourceEntityID"`
TargetEntity *Entity `gorm:"foreignKey:TargetEntityID"`
}
EntityRelation represents relationships between entities
func (EntityRelation) TableName ¶
func (EntityRelation) TableName() string
type File ¶
type File struct {
ID int64 `gorm:"primaryKey"`
Path string `gorm:"uniqueIndex;not null"`
Language string `gorm:"not null"`
Hash string
Entities []Entity `gorm:"foreignKey:FileID;constraint:OnDelete:CASCADE"`
Dependencies []Dependency `gorm:"foreignKey:SourceFileID;constraint:OnDelete:CASCADE"`
}
File represents a source file in the codebase