Documentation
¶
Index ¶
- func Hash(data []byte) (uint64, error)
- type Asset
- type Config
- type Constant
- type ContentGenerator
- type Document
- type DocumentKind
- type Documents
- type Emitter
- type Field
- type File
- func (f *File) Content(generator Emitter) ([]byte, error)
- func (f *File) GetConstant(name string) *Constant
- func (f *File) HasFunction(name string) bool
- func (f *File) IndexFunctions()
- func (f *File) IndexTypes()
- func (f *File) LookupFunction(name string) *Function
- func (f *File) LookupType(name string) *Type
- func (f *File) LookupVariable(name string) *Variable
- type Function
- type Import
- type Location
- type LocationNode
- type Package
- type Parameter
- type PomInfo
- type Project
- type Type
- func (t *Type) AddField(field *Field)
- func (t *Type) AddMethod(method *Function)
- func (t *Type) Clone() *Type
- func (m *Type) Content() string
- func (f *Type) GetField(name string) *Field
- func (f *Type) GetMethod(name string) *Function
- func (t *Type) RemoveField(fieldName string) bool
- func (t *Type) RemoveMethod(methodName string) bool
- type TypeParam
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
IncludeUnexported bool
SkipTests bool
RecursivePackages bool
SkipAsset bool //
}
func DefaultConfig ¶
func DefaultConfig() *Config
type ContentGenerator ¶
type ContentGenerator interface {
// Generate generates content from a file
Emit(file *File) ([]byte, error)
}
ContentGenerator defines an interface for generating content from a file
type Document ¶
type Document struct {
ID string `json:"id"` // Unique identifier for the document
Kind DocumentKind `json:"kind"` // Kind of document
Project string `json:"project"` // Project name
Path string `json:"path"` // File path
Package string `json:"package"` // Package name
Name string `json:"name"` // Element name
Type string `json:"type"` // Type of the element (e.g., function signature)
Hash uint64 `json:"hash"` // Hash of the content
Signature string `json:"signature"` //Signature
Content string `json:"content"` // Full content of the element including comments, annotations, etc.
Part int `json:"part"` // Part number for large documents
}
Document represents a code element with its metadata for vector embedding
func (*Document) HashContent ¶
HashContent generates content hash
type DocumentKind ¶
type DocumentKind string
DocumentKind indicates the type of code element that the document represents
const ( // Document kinds KindConstant DocumentKind = "Constant" KindVariable DocumentKind = "Variable" KindFileFunc DocumentKind = "Function" // Function without a receiver KindType DocumentKind = "Type" // Type declaration only KindTypeMethod DocumentKind = "Method" KindTypeField DocumentKind = "Field" KindAsset DocumentKind = "Asset" // Package-level information KindCode DocumentKind = "Code" // Package-level information )
type Documents ¶
type Documents []*Document
func SplitDocument ¶
SplitDocument splits a large document into multiple chunks of 8k - 256 bytes.
func (Documents) FilterBySize ¶
type Field ¶
type Field struct {
Name string
Type *Type
Tag reflect.StructTag
Location *Location
Comment string
Annotation string
IsExported bool
IsEmbedded bool
IsStatic bool
IsConstant bool
}
Field represents a struct field
type File ¶
type File struct {
Name string // File name
Path string // File path
Package string // Package name
ImportPath string // Import path
Types []*Type // Types declared in this file
Constants []*Constant // Constants declared in this file
Variables []*Variable // Variables declared in this file
Functions []*Function // Functions declared in this file
Imports []Import // Imports used in this file
// contains filtered or unexported fields
}
File represents a source code file with its types and symbols
func (*File) GetConstant ¶
GetConstant retrieves a constant by name from the file
func (*File) HasFunction ¶
HasFunction checks if a function with the given name exists in the file
func (*File) IndexFunctions ¶
func (f *File) IndexFunctions()
func (*File) IndexTypes ¶
func (f *File) IndexTypes()
func (*File) LookupFunction ¶
LookupFunction retrieves a function by name from the file
func (*File) LookupType ¶
LookupType retrieves a type by name from the file
func (*File) LookupVariable ¶
LookupVariable retrieves a variable by name from the file
type Function ¶
type Function struct {
Name string
Comment *LocationNode
Annotation *LocationNode
Receiver string
TypeParams []*TypeParam
Parameters []*Parameter
Results []*Parameter
Body *LocationNode
IsExported bool
Location *Location // Location of the method in the source code
IsStatic bool // Whether the method is static (class method)
IsConstructor bool
Signature string
Hash int32
}
Function represents a type method
type Import ¶
type Import struct {
Name string // Local name (may be empty for default)
Path string // Import path
}
Import represents an imported package
type LocationNode ¶
func NewNodeLocation ¶
func NewNodeLocation(text string) *LocationNode
type Package ¶
type Package struct {
Name string
ImportPath string
FileSet []*File // Files that are part of this package
Assets []*Asset // Assets associated with this package
// contains filtered or unexported fields
}
Package represents a Go package with its files and types
func (*Package) IndexTypes ¶
func (p *Package) IndexTypes()
func (*Package) LookupMethod ¶
type Project ¶
type Project struct {
Name string
Type string
RootPath string
RepositoryURL string
Packages []*Package
// contains filtered or unexported fields
}
Project represents a code project with multiple packages
func (*Project) AddFunctionToFile ¶
func (p *Project) AddFunctionToFile(packageName, fileName, functionName, functionContent string) error
AddFunctionToFile adds a function to a file if it doesn't already exist
func (*Project) CreateDocuments ¶
CreateDocuments creates Document instances for embedding from a project
func (*Project) GetPackage ¶
GetPackage retrieves a constant by name from the file
type Type ¶
type Type struct {
Name string // Type name
Kind reflect.Kind // Go reflect kind
Tag reflect.StructTag // Tags for struct fields
Package string // Package name
PackagePath string // Full package import path
ComponentType string // For container types (slices, maps)
KeyType string // For map types
Comment *LocationNode // Type documentation
Annotation *LocationNode // Annotations for the type
IsExported bool // Whether the type is exported
Fields []*Field // Struct fields (if applicable)
Methods []*Function // Type methods
TypeParams []*TypeParam // Generic type parameters
Implements []string // Interfaces this type implements
IsPointer bool // Whether the type is a pointer
Location *Location // Location of the type in the source code
Extends []string
// contains filtered or unexported fields
}
Type represents a parsed Go type with rich metadata
func CreateCompositeType ¶
func CreateCompositeType(name string, sourceTypes []*Type, fieldNames [][]string, methodNames [][]string) *Type
CreateCompositeType creates a new type by combining fields and methods from multiple types
func CreateTypeFromFields ¶
CreateTypeFromFields creates a new type with the given name and selected fields
func CreateTypeFromMethods ¶
CreateTypeFromMethods creates a new type with the given name and selected methods
func (*Type) Content ¶
Content returns the content of the method including its receiver, parameters, and results
func (*Type) RemoveField ¶
RemoveField removes a field from the type by name
func (*Type) RemoveMethod ¶
RemoveMethod removes a method from the type by name
type Variable ¶
type Variable struct {
Name string
Comment string
Type *Type
Value string
File *File // File where this variable is defined
IsExported bool // Whether the variable is exported (public) or not
Annotation string // Annotation associated with the variable
IsConst bool // Whether the variable is a constant
Location *Location // Location of the variable in the source code
}