cbm

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ParseTimeoutMicros = 10_000_000

ParseTimeoutMicros is the default per-file parse timeout (10 seconds).

Variables

This section is empty.

Functions

func Init

func Init()

Init initializes the C library. Safe to call multiple times.

func Shutdown

func Shutdown()

Shutdown cleans up the C library.

Types

type Call

type Call struct {
	CalleeName      string
	EnclosingFuncQN string
	DispatchKind    string
	// CalleeIsLocallyBound: a bare call whose callee is a parameter of an
	// enclosing function; the resolver must not bind it to a project symbol.
	CalleeIsLocallyBound bool
}

Call represents a raw call site (callee name + enclosing function).

DispatchKind labels calls synthesized by an indirect-dispatch pattern rather than appearing literally in source. Empty for ordinary direct calls. Set by the C extractor on:

  • "executor_submit" : <pool>.submit(fn, ...) — concurrent.futures
  • "depends" : FastAPI Depends(fn)
  • "getattr" : getattr(obj, "method")(...)

Consumed by the pipeline to label the resulting CALLS edge with properties.dispatch_kind + properties.confidence so trace_call_path can distinguish direct from indirect resolutions for confidence-band calculation.

type CrossFileDef

type CrossFileDef struct {
	QualifiedName string
	ShortName     string
	Label         string // "Function", "Method", "Type", "Interface"
	ReceiverType  string // for methods: receiver type QN
	DefModuleQN   string // module QN where this def lives
	ReturnTypes   string // "|"-separated return type texts (e.g., "*File|error")
	EmbeddedTypes string // "|"-separated embedded type QNs
	FieldDefs     string // "|"-separated "name:type" pairs (for struct fields, e.g. "Binder:Binder|Name:string")
	MethodNames   string // "|"-separated method names for interfaces (e.g. "Get|Put|Delete")
	IsInterface   bool
}

CrossFileDef represents a definition from another file for cross-file LSP resolution.

func DefsToLSPDefs

func DefsToLSPDefs(defs []Definition, moduleQN string) []CrossFileDef

DefsToLSPDefs converts file-local Definition slice to CrossFileDef format.

type Definition

type Definition struct {
	Name            string
	QualifiedName   string
	Label           string // "Function", "Method", "Class", "Variable", "Module", "Interface", "Enum", "Type"
	FilePath        string
	StartLine       int
	EndLine         int
	Signature       string
	ReturnType      string
	Receiver        string
	Docstring       string
	ParentClass     string
	Decorators      []string
	BaseClasses     []string
	ExtendsTypes    []string
	ImplementsTypes []string
	ParamNames      []string
	ParamTypes      []string
	ReturnTypes     []string
	Complexity      int
	Lines           int
	IsExported      bool
	IsAbstract      bool
	IsTest          bool
	IsEntryPoint    bool
}

Definition represents a function/class/variable/module extracted from source.

type EnvAccess

type EnvAccess struct {
	EnvKey          string
	EnclosingFuncQN string
}

EnvAccess represents an environment variable access.

type FileResult

type FileResult struct {
	Definitions   []Definition
	Calls         []Call
	Imports       []Import
	Usages        []Usage
	Throws        []Throw
	ReadWrites    []ReadWrite
	TypeRefs      []TypeRef
	EnvAccesses   []EnvAccess
	TypeAssigns   []TypeAssign
	ImplTraits    []ImplTrait
	ResolvedCalls []ResolvedCall

	ModuleQN    string
	IsTestFile  bool
	ImportCount int
	// DepthCapped is true when an AST walk hit the recursion ceiling and
	// skipped a subtree; the file was indexed partially rather than crashing.
	DepthCapped bool
}

FileResult holds the extraction results from one file.

func ExtractFile

func ExtractFile(source []byte, language lang.Language, project, relPath string) (*FileResult, error)

ExtractFile runs the C extraction library on one file. source is the file content, language is the programming language, project and relPath are used for qualified name computation.

type ImplTrait

type ImplTrait struct {
	TraitName  string
	StructName string
}

ImplTrait represents a Rust `impl Trait for Struct` pair.

type Import

type Import struct {
	LocalName      string
	ModulePath     string
	DependencyOnly bool
}

Import represents a local name -> module path mapping.

type ProfileStats

type ProfileStats struct {
	ParseNs   uint64
	ExtractNs uint64
	Files     uint64
}

ProfileStats holds accumulated profiling data from C extraction.

func GetProfile

func GetProfile() ProfileStats

GetProfile returns accumulated parse/extraction timing and resets counters.

type ReadWrite

type ReadWrite struct {
	VarName         string
	EnclosingFuncQN string
	IsWrite         bool
}

ReadWrite represents a variable read or write.

type ResolvedCall

type ResolvedCall struct {
	CallerQN   string
	CalleeQN   string
	Strategy   string
	Confidence float32
	Reason     string // diagnostic label for unresolved calls (empty if resolved)
}

ResolvedCall represents a high-confidence type-aware call resolution from LSP.

func RunGoLSPCrossFile

func RunGoLSPCrossFile(
	source []byte,
	moduleQN string,
	fileDefs []CrossFileDef,
	crossDefs []CrossFileDef,
	imports []Import,
) []ResolvedCall

RunGoLSPCrossFile runs the Go LSP type resolver with cross-file definitions. source is the file content, moduleQN is the file's module QN, fileDefs are the file's own definitions (converted to CrossFileDef format), crossDefs are definitions from imported packages, imports are the file's import mappings. Returns resolved calls with high confidence.

type Throw

type Throw struct {
	ExceptionName   string
	EnclosingFuncQN string
}

Throw represents a throw/raise statement.

type TypeAssign

type TypeAssign struct {
	VarName         string
	TypeName        string
	EnclosingFuncQN string
}

TypeAssign represents a variable assignment where RHS is a constructor call.

type TypeRef

type TypeRef struct {
	TypeName        string
	EnclosingFuncQN string
}

TypeRef represents a type reference in a function signature or body.

type Usage

type Usage struct {
	RefName         string
	EnclosingFuncQN string
}

Usage represents a reference to an identifier (not a call or import).

Directories

Path Synopsis
Package isolate runs tree-sitter extraction in supervised worker processes so a crashing or hanging file is skipped and reported instead of taking the whole indexer (and the MCP server around it) down.
Package isolate runs tree-sitter extraction in supervised worker processes so a crashing or hanging file is skipped and reported instead of taking the whole indexer (and the MCP server around it) down.

Jump to

Keyboard shortcuts

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