semantic

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 27 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(value []byte) string

Hash returns the lowercase SHA-256 hex digest used for semantic declaration identity.

Types

type Analyzer

type Analyzer struct{}

Analyzer implements code.SemanticAnalyzer using tree-sitter grammars. Install it with code.WithSemanticAnalyzer(semantic.New()) or SetSemanticAnalyzer.

func New

func New() *Analyzer

New returns a tree-sitter backed semantic analyzer.

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

func (a *Analyzer) Language(path string) (string, bool)

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.

func (*Analyzer) ValidateSyntax

func (a *Analyzer) ValidateSyntax(ctx context.Context, path string, body []byte) error

ValidateSyntax reports whether body parses as valid source for path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL