Documentation
¶
Overview ¶
Package codeintel provides code intelligence primitives backed by package loading, language adapters, incremental persistence, and provenance-aware graph metadata.
Index ¶
- Constants
- type BuildContext
- type CallEdge
- type CodeDefinition
- type CodeDiagnostic
- type CodeFile
- type CodeReference
- type CodeRelationship
- type CodeSymbol
- type Declaration
- type Diagnostic
- type File
- type ImpactQuery
- type ImpactResult
- type Import
- type ImportEdge
- type Index
- func (idx Index) AnalyzeImpact(query ImpactQuery) ImpactResult
- func (idx Index) FindCallees(name string) []CallEdge
- func (idx Index) FindCallers(name string) []CallEdge
- func (idx Index) FindDefinitions(name string) []Declaration
- func (idx Index) FindImports(importPath string) []Import
- func (idx Index) FindReferences(name string) []Reference
- func (idx Index) FindSymbol(name string) []Symbol
- func (idx Index) PublicAPI(packageNameOrPath string) []Declaration
- func (idx Index) Query(query Query) QueryResult
- type IndexOptions
- type IndexStats
- type Indexer
- func (idxr *Indexer) IndexDir(root string) (Index, error)
- func (idxr *Indexer) IndexDirContext(ctx context.Context, root string) (Index, error)
- func (idxr *Indexer) IndexDirWithOptions(root string, opts IndexOptions) (Index, error)
- func (idxr *Indexer) IndexDirWithOptionsContext(ctx context.Context, root string, opts IndexOptions) (Index, error)
- func (idxr *Indexer) IndexFiles(paths []string) (Index, error)
- func (idxr *Indexer) IndexFilesContext(ctx context.Context, paths []string) (Index, error)
- type Model
- type PackageInfo
- type Provenance
- type Query
- type QueryKind
- type QueryResult
- type Reference
- type SourceFile
- type SourceRange
- type Symbol
- type WorkspaceIndexOptions
- type WorkspaceIndexer
Constants ¶
const ( // LanguageGo identifies Go source files in the language-neutral model. LanguageGo = "go" // LanguagePython identifies Python source files in the language-neutral model. LanguagePython = "python" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildContext ¶
type BuildContext struct {
GOOS string
GOARCH string
Tags []string
Test bool
Generated bool
PackageID string
PackagePath string
ModulePath string
}
BuildContext records the build settings that made a file or edge visible.
func (BuildContext) String ¶
func (ctx BuildContext) String() string
String returns a stable compact build-context description for graph evidence.
type CallEdge ¶
type CallEdge struct {
CallerID string
CalleeID string
File string
Range SourceRange
Build BuildContext
Provenance Provenance
}
CallEdge describes one type-resolved call relationship between declarations.
type CodeDefinition ¶ added in v0.0.7
type CodeDefinition struct {
Provenance Provenance
ID string
Name string
Kind string
Language string
File string
ContainerID string
ContainerName string
Range SourceRange
Exported bool
}
CodeDefinition is a language-neutral declaration or definition.
type CodeDiagnostic ¶ added in v0.0.7
type CodeDiagnostic struct {
ID string
Language string
File string
Source string
Severity string
Message string
Range SourceRange
}
CodeDiagnostic describes an indexing or language-server diagnostic.
type CodeFile ¶ added in v0.0.7
type CodeFile struct {
ModTime time.Time
Provenance Provenance
ID string
Path string
Language string
ContentHash string
Range SourceRange
Size int64
}
CodeFile describes one indexed source file independent of parser or language.
type CodeReference ¶ added in v0.0.7
type CodeReference struct {
Provenance Provenance
ID string
Name string
Kind string
Language string
File string
FromID string
ToID string
Range SourceRange
}
CodeReference is a language-neutral identifier/reference edge endpoint.
type CodeRelationship ¶ added in v0.0.7
type CodeRelationship struct {
FromID string
ToID string
Kind string
Language string
File string
Provenance []Provenance
Range SourceRange
}
CodeRelationship describes one typed relationship between model items.
type CodeSymbol ¶ added in v0.0.7
type CodeSymbol struct {
Provenance Provenance
ID string
Name string
Kind string
Language string
File string
ContainerID string
DefinitionID string
Range SourceRange
}
CodeSymbol is a named item exposed by a language adapter. Symbols may point at definitions when the adapter can resolve declaration identity.
type Declaration ¶
type Declaration struct {
ID string
Name string
Kind string
PackageName string
PackageID string
PackagePath string
Receiver string
File string
Range SourceRange
Exported bool
Build BuildContext
Provenance Provenance
}
Declaration describes a top-level API or implementation declaration.
type Diagnostic ¶
Diagnostic records package loader errors that did not prevent a partial index.
type File ¶
File summarizes one parsed Go source file.
File intentionally keeps the legacy summary shape used by existing CLI commands. Rich file metadata lives in SourceFile.
type ImpactQuery ¶
ImpactQuery asks how a file, import path, or symbol affects the indexed code.
type ImpactResult ¶
type ImpactResult struct {
DirectImports []Import
ReverseImports []Import
References []Reference
Callers []CallEdge
PublicAPIDeclarations []Declaration
Evidence []Provenance
Uncertainty []string
}
ImpactResult separates import, reference, and public API evidence so callers can distinguish why a change may matter.
type Import ¶
type Import struct {
ID string
Path string
Alias string
File string
PackageID string
PackagePath string
ResolvedPackagePath string
Range SourceRange
Build BuildContext
Provenance Provenance
}
Import describes one source import with evidence and build context.
type ImportEdge ¶
ImportEdge describes one file-level import relationship.
ImportEdge intentionally keeps the legacy small shape used by existing import graph commands. Rich import metadata lives in Import.
type Index ¶
type Index struct {
Files []File
Symbols []Symbol
ImportEdges []ImportEdge
Packages []PackageInfo
FileDetails []SourceFile
Declarations []Declaration
Imports []Import
References []Reference
CallEdges []CallEdge
Graph *codegraph.EvidenceGraph
Diagnostics []Diagnostic
Model Model
Stats IndexStats
}
Index contains legacy summaries plus semantic code intelligence data.
func IndexDirContext ¶
IndexDirContext parses all active Go source files under root using ctx for package-loading cancellation.
func IndexFiles ¶
IndexFiles parses the provided Go source files.
func IndexFilesContext ¶
IndexFilesContext parses the provided Go source files using ctx for package-loading cancellation.
func (Index) AnalyzeImpact ¶
func (idx Index) AnalyzeImpact(query ImpactQuery) ImpactResult
AnalyzeImpact answers file/import/symbol impact questions with evidence and uncertainty instead of returning naked graph node IDs.
func (Index) FindCallees ¶
FindCallees returns call edges whose caller is a declaration matching name.
func (Index) FindCallers ¶
FindCallers returns call edges whose callee is a declaration matching name.
func (Index) FindDefinitions ¶
func (idx Index) FindDefinitions(name string) []Declaration
FindDefinitions returns semantic declarations with the exact name.
func (Index) FindImports ¶
FindImports returns imports matching the exact import path.
func (Index) FindReferences ¶
FindReferences returns semantic references to declarations with the exact target name or identifier name.
func (Index) FindSymbol ¶
FindSymbol returns symbols with the exact name.
func (Index) PublicAPI ¶
func (idx Index) PublicAPI(packageNameOrPath string) []Declaration
PublicAPI returns exported declarations, optionally scoped to a package name, package path, or package ID.
func (Index) Query ¶ added in v0.0.7
func (idx Index) Query(query Query) QueryResult
Query executes a language-neutral model query against idx.
type IndexOptions ¶
type IndexOptions struct {
// Tags are passed as -tags to the Go package loader.
Tags []string
// Env augments or overrides the process environment used by the package loader.
Env []string
// ExcludeTests omits _test.go files and package test variants.
ExcludeTests bool
// ExcludeGenerated omits files matching Go's generated-code convention.
ExcludeGenerated bool
}
IndexOptions controls package-aware indexing.
type IndexStats ¶
type IndexStats struct {
CacheHit bool
FilesScanned int
FilesReused int
FilesChanged int
FilesDeleted int
}
IndexStats describes cache behavior for an indexing run.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer caches whole-index results by file mtimes and content hashes so repeated indexing of unchanged workspaces avoids package reloads.
func NewIndexer ¶
func NewIndexer() *Indexer
NewIndexer returns an incremental package-aware indexer.
func (*Indexer) IndexDir ¶
IndexDir parses all active Go source files under root using this indexer's cache.
func (*Indexer) IndexDirContext ¶
IndexDirContext parses all active Go source files under root using this indexer's cache and ctx for package-loading cancellation.
func (*Indexer) IndexDirWithOptions ¶
func (idxr *Indexer) IndexDirWithOptions(root string, opts IndexOptions) (Index, error)
IndexDirWithOptions parses all active Go source files under root using options.
func (*Indexer) IndexDirWithOptionsContext ¶
func (idxr *Indexer) IndexDirWithOptionsContext(ctx context.Context, root string, opts IndexOptions) (Index, error)
IndexDirWithOptionsContext parses all active Go source files under root using options and ctx for package-loading cancellation.
func (*Indexer) IndexFiles ¶
IndexFiles parses the provided Go source files using this indexer's cache.
type Model ¶ added in v0.0.7
type Model struct {
Files []CodeFile
Symbols []CodeSymbol
Definitions []CodeDefinition
References []CodeReference
Diagnostics []CodeDiagnostic
Relationships []CodeRelationship
Stats IndexStats
}
Model is the language-neutral code-intelligence index that higher-level query surfaces should use. The legacy Index fields remain for existing Go-specific CLI responses; Model is intentionally shaped around files, symbols, definitions, references, diagnostics, and relationships across languages.
func (Model) Query ¶ added in v0.0.7
func (model Model) Query(query Query) QueryResult
Query executes a language-neutral model query.
type PackageInfo ¶
type PackageInfo struct {
ID string
Name string
Path string
ModulePath string
Files []string
Test bool
}
PackageInfo describes one loaded package or package test variant.
type Provenance ¶
type Provenance struct {
Source string
Range SourceRange
Build BuildContext
Confidence string
}
Provenance records why an index item exists.
type Query ¶ added in v0.0.7
type Query struct {
Kind QueryKind
Name string
File string
Language string
FromID string
ToID string
RelationshipKind string
}
Query is a small language-neutral query shape the CLI can sit on top of instead of adding one flag for every index projection.
type QueryKind ¶ added in v0.0.7
type QueryKind string
QueryKind selects the language-neutral query surface backed by Index.Model.
const ( // QueryFiles returns indexed files. QueryFiles QueryKind = "files" // QuerySymbols returns named symbols. QuerySymbols QueryKind = "symbols" // QueryDefinitions returns definitions/declarations. QueryDefinitions QueryKind = "definitions" // QueryReferences returns references. QueryReferences QueryKind = "references" // QueryDiagnostics returns diagnostics. QueryDiagnostics QueryKind = "diagnostics" // QueryRelationships returns typed code graph relationships. QueryRelationships QueryKind = "relationships" )
type QueryResult ¶ added in v0.0.7
type QueryResult struct {
Files []CodeFile
Symbols []CodeSymbol
Definitions []CodeDefinition
References []CodeReference
Diagnostics []CodeDiagnostic
Relationships []CodeRelationship
Uncertainty []string
}
QueryResult contains the model records selected by Query plus uncertainty for empty or unsupported requests.
type Reference ¶
type Reference struct {
ID string
Name string
Kind string
File string
FromPackageID string
FromDeclarationID string
ToDeclarationID string
Range SourceRange
Build BuildContext
Provenance Provenance
}
Reference describes one type-resolved identifier reference.
type SourceFile ¶
type SourceFile struct {
Path string
PackageName string
PackageID string
PackagePath string
ModulePath string
Generated bool
Test bool
BuildTags []string
Range SourceRange
ContentHash string
Size int64
ModTime time.Time
Build BuildContext
Provenance Provenance
}
SourceFile describes one loaded source file with build and cache metadata.
type SourceRange ¶
SourceRange identifies a source span in a file.
type Symbol ¶
Symbol describes a named declaration in a Go source file.
Symbol intentionally keeps the legacy small shape used by existing CLI summaries. Rich definition metadata lives in Declaration.
type WorkspaceIndexOptions ¶ added in v0.0.7
type WorkspaceIndexOptions struct {
CachePath string
Go IndexOptions
}
WorkspaceIndexOptions configures the multi-language code-intelligence subsystem. Go controls the existing package-aware Go adapter. CachePath, when set, stores a deterministic JSON snapshot that can be reused across runs.
type WorkspaceIndexer ¶ added in v0.0.7
type WorkspaceIndexer struct {
// contains filtered or unexported fields
}
WorkspaceIndexer coordinates language adapters, persistence, and invalidation for a workspace-level code-intelligence index.
func NewWorkspaceIndexer ¶ added in v0.0.7
func NewWorkspaceIndexer(options WorkspaceIndexOptions) *WorkspaceIndexer
NewWorkspaceIndexer returns a multi-language workspace indexer.
func (*WorkspaceIndexer) IndexDir ¶ added in v0.0.7
func (idxr *WorkspaceIndexer) IndexDir(root string) (Index, error)
IndexDir indexes a workspace without a caller-supplied deadline. Prefer IndexDirContext when callers already have a request context.
func (*WorkspaceIndexer) IndexDirContext ¶ added in v0.0.7
IndexDirContext indexes supported languages under root, reusing a persisted snapshot when every supported file fingerprint is unchanged.