Documentation
¶
Overview ¶
Package semantic holds the tree-sitter source-analysis stack that the base code server deliberately omits. Importing it pulls the tree-sitter CGO grammars, so only tools that need source semantics depend on it; Go service agents keep core/code CGO-free and build with CGO_ENABLED=0.
Index ¶
- func Hash(value []byte) string
- type Analyzer
- func (a *Analyzer) DeclarationSpans(ctx context.Context, path string, body []byte) ([]code.SymbolSpan, error)
- func (a *Analyzer) InspectProject(ctx context.Context, fs code.VFS, sourceDir, language string, ...) error
- func (a *Analyzer) Language(path string) (string, bool)
- func (a *Analyzer) SemanticIndex(ctx context.Context, sourceDir string, fs code.VFS) (*basev0.SemanticIndex, error)
- func (a *Analyzer) SourceImports(ctx context.Context, vfs code.VFS, root, language string) ([]*codev0.SourceFileInfo, error)
- func (a *Analyzer) ValidateSyntax(ctx context.Context, path string, body []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Analyzer ¶
type Analyzer struct{}
Analyzer implements code.SemanticAnalyzer using tree-sitter grammars. Install it with code.WithSemanticAnalyzer(semantic.New()) or SetSemanticAnalyzer.
func (*Analyzer) DeclarationSpans ¶
func (a *Analyzer) DeclarationSpans(ctx context.Context, path string, body []byte) ([]code.SymbolSpan, error)
DeclarationSpans returns every declaration span in body, keyed for typed symbol mutation.
func (*Analyzer) InspectProject ¶
func (a *Analyzer) InspectProject(ctx context.Context, fs code.VFS, sourceDir, language string, info *codev0.GetProjectInfoResponse) error
InspectProject fills declarative project metadata for a JVM or .NET code unit. Other languages are rejected: their inspection belongs to a dedicated language agent.
func (*Analyzer) Language ¶
Language returns the semantic language name for path and whether typed symbol mutation supports it.
func (*Analyzer) SemanticIndex ¶
func (a *Analyzer) SemanticIndex(ctx context.Context, sourceDir string, fs code.VFS) (*basev0.SemanticIndex, error)
SemanticIndex performs one deterministic scan through the server VFS. Parse failures degrade individual files while retaining valid evidence from the rest of the code unit. An unsupported unit is explicit, never an empty response that a caller could mistake for complete coverage.
func (*Analyzer) SourceImports ¶
func (a *Analyzer) SourceImports(ctx context.Context, vfs code.VFS, root, language string) ([]*codev0.SourceFileInfo, error)
SourceImports returns a deterministic per-file inventory. A syntax error fails the inspection instead of silently certifying incomplete source evidence as authoritative. The Go inventory is stdlib-based and lives in core/code; this analyzer covers the tree-sitter languages.