Documentation
¶
Overview ¶
Package parse extracts symbols and references from source files.
v0.1 supports Python only, via the canonical C tree-sitter runtime exposed to Go through github.com/tree-sitter/go-tree-sitter (CGO).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RefKind ¶
type RefKind string
RefKind classifies a reference site. Values mirror the MCP tool schema.
type Reference ¶
Reference is a single textual reference to a name at a source location.
Line and Col are 1-based to match what users see in editors. Col is the byte column at the start of the identifier. Name is the bare identifier as written at the call/import/subclass site (not resolved); v0.1 is textual, so a `Foo()` call and a `Foo()` constructor share the same name.
func ParsePythonRefs ¶
ParsePythonRefs returns every reference site in src: function calls, names brought in by `import`/`from x import y`, and superclasses on class definitions. Attribute access (`obj.foo`) is not emitted in v0.1 — it would flood results without semantic disambiguation.
type Symbol ¶
type Symbol struct {
Name string
Qualified string
Kind SymbolKind
StartLine int
EndLine int
Signature string
Docstring string
}
Symbol is a single named definition extracted from a source file.
Line numbers are 1-based and inclusive, matching what users see in editors. Qualified is the dotted path within the file (e.g. "Greeter.greet"); the indexer prepends the module path at insert time. Signature is the def line up to but not including the body, with the trailing colon trimmed; empty for classes and assignments. Docstring is the first paragraph of the body's docstring if present, truncated to 500 characters.
func ParsePython ¶
ParsePython returns every named definition (function, class, method) in src. Qualified names are dotted paths within the file: a top-level function gets Qualified == Name; a method on Greeter gets Qualified == "Greeter.greet".
ParsePythonTopLevel is preserved for callers that only want module-level items; it is now a thin filter over ParsePython.
func ParsePythonTopLevel ¶
ParsePythonTopLevel returns only the module-level functions and classes.
type SymbolKind ¶
type SymbolKind string
SymbolKind classifies a parsed symbol. Values are stable strings because they are persisted to the on-disk index and surfaced through MCP tools.
const ( KindFunction SymbolKind = "function" KindClass SymbolKind = "class" KindMethod SymbolKind = "method" KindVariable SymbolKind = "variable" KindConstant SymbolKind = "constant" )