treesitter

package
v0.267.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package treesitter provides AST walking and symbol extraction utilities.

Package treesitter provides C language symbol extraction.

Package treesitter provides Go language symbol extraction.

Package treesitter provides Java language symbol extraction.

Package treesitter provides JavaScript language symbol extraction.

Package treesitter provides Kotlin language symbol extraction.

Package treesitter provides language mappings and grammar access for tree-sitter parsing.

Package treesitter provides Lua language symbol extraction.

Package treesitter provides Markdown language symbol extraction.

Package treesitter provides tree-sitter based parsing for code indexing.

Package treesitter provides PHP language symbol extraction.

Package treesitter provides Python language symbol extraction.

Package treesitter provides Rust language symbol extraction.

Package treesitter provides Svelte language symbol extraction.

Package treesitter provides Swift language symbol extraction.

Package treesitter provides TOML language symbol extraction.

Package treesitter provides tree-sitter based parsing and AST extraction for code indexing.

Package treesitter provides TypeScript language symbol extraction.

Package treesitter provides Vue language symbol extraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindChildByType

func FindChildByType(node *sitter.Node, nodeType string) *sitter.Node

FindChildByType finds the first child of a specific type

func FindChildrenByType

func FindChildrenByType(node *sitter.Node, nodeType string) []*sitter.Node

FindChildrenByType finds all children of a specific type

func FindNamedChildByType

func FindNamedChildByType(node *sitter.Node, nodeType string) *sitter.Node

FindNamedChildByType finds the first named child of a specific type

func GetGrammar

func GetGrammar(lang Language) (*sitter.Language, bool)

GetGrammar returns the tree-sitter grammar for a Language

func GetNodeContent

func GetNodeContent(node *sitter.Node, sourceCode []byte) string

GetNodeContent returns the source code content for a node

func GetNodeLocation

func GetNodeLocation(node *sitter.Node) (startLine, endLine int, startByte, endByte int)

GetNodeLocation returns line and byte information for a node

func GetSupportedExtensions

func GetSupportedExtensions() []string

GetSupportedExtensions returns all supported file extensions

func IsLanguageSupported

func IsLanguageSupported(lang Language) bool

IsLanguageSupported returns true if the language is supported

func IsSupportedFile

func IsSupportedFile(filePath string) bool

IsSupportedFile returns true if the file is a supported source file

func IterateNamedChildren

func IterateNamedChildren(node *sitter.Node) []*sitter.Node

IterateNamedChildren iterates over named children of a node

Types

type ASTWalker

type ASTWalker struct {
	// contains filtered or unexported fields
}

ASTWalker provides utilities for walking the AST and extracting symbols

func NewASTWalker

func NewASTWalker(config WalkerConfig) *ASTWalker

NewASTWalker creates a new AST walker with the given configuration

func (*ASTWalker) ExtractSymbols

func (w *ASTWalker) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, lang Language, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts symbols from a parsed tree using the appropriate extractor

func (*ASTWalker) GetExtractor

func (w *ASTWalker) GetExtractor(lang Language) (SymbolExtractor, bool)

GetExtractor returns the extractor for a language

func (*ASTWalker) RegisterExtractor

func (w *ASTWalker) RegisterExtractor(extractor SymbolExtractor)

RegisterExtractor adds a new extractor for a language

type BaseExtractor

type BaseExtractor struct {
	// contains filtered or unexported fields
}

BaseExtractor provides common functionality for all extractors

func NewBaseExtractor

func NewBaseExtractor(lang Language, config WalkerConfig) BaseExtractor

NewBaseExtractor creates a new base extractor

func (*BaseExtractor) BuildNamePath

func (b *BaseExtractor) BuildNamePath(parentPath string, name string) string

BuildNamePath creates a hierarchical path for a symbol

func (*BaseExtractor) CreateSymbol

func (b *BaseExtractor) CreateSymbol(
	node *sitter.Node,
	sourceCode []byte,
	symbolType SymbolType,
	name string,
	namePath string,
	filePath string,
	projectID string,
	parentID *string,
) *CodeSymbol

CreateSymbol creates a new CodeSymbol from a node

func (*BaseExtractor) ExtractDocString

func (b *BaseExtractor) ExtractDocString(node *sitter.Node, sourceCode []byte) string

ExtractDocString extracts documentation comment before a node

func (*BaseExtractor) Language

func (b *BaseExtractor) Language() Language

Language returns the language this extractor handles

type CExtractor

type CExtractor struct {
	BaseExtractor
}

CExtractor extracts symbols from C source code

func NewCExtractor

func NewCExtractor(config WalkerConfig) *CExtractor

NewCExtractor creates a new C extractor

func (*CExtractor) ExtractSymbols

func (c *CExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from C source code

func (*CExtractor) GetSymbolTypes

func (c *CExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the C extractor can find

type CodeFile

type CodeFile struct {
	// Project identifier
	ProjectID string `json:"project_id"`

	// Relative file path
	FilePath string `json:"file_path"`

	// Detected language
	Language Language `json:"language"`

	// SHA-256 hash for change detection
	FileHash string `json:"file_hash"`

	// Number of symbols in this file
	SymbolsCount int `json:"symbols_count"`

	// When this file was indexed
	IndexedAt time.Time `json:"indexed_at"`
}

CodeFile represents an indexed source file

type CodeProject

type CodeProject struct {
	// Unique project identifier
	ProjectID string `json:"project_id"`

	// Human-readable name
	Name string `json:"name"`

	// Root path on disk
	RootPath string `json:"root_path"`

	// Statistics by language
	LanguageStats map[Language]int `json:"language_stats"`

	// Last time the project was indexed
	LastIndexedAt *time.Time `json:"last_indexed_at,omitempty"`

	// Current indexing status
	IndexingStatus IndexingStatus `json:"indexing_status"`

	// Timestamps
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

CodeProject represents an indexed code project

type CodeSymbol

type CodeSymbol struct {
	// Unique identifier for the symbol
	ID string `json:"id"`

	// Project this symbol belongs to
	ProjectID string `json:"project_id"`

	// Relative file path within the project
	FilePath string `json:"file_path"`

	// Programming language
	Language Language `json:"language"`

	// Type of symbol (class, method, function, etc.)
	SymbolType SymbolType `json:"symbol_type"`

	// Name of the symbol
	Name string `json:"name"`

	// Hierarchical path within the file (e.g., "MyClass/myMethod")
	NamePath string `json:"name_path"`

	// Location in source file
	StartLine int `json:"start_line"`
	EndLine   int `json:"end_line"`
	StartByte int `json:"start_byte"`
	EndByte   int `json:"end_byte"`

	// Source code content
	SourceCode string `json:"source_code,omitempty"`

	// Signature (for methods/functions)
	Signature string `json:"signature,omitempty"`

	// Documentation string
	DocString string `json:"doc_string,omitempty"`

	// Vector embedding (populated later during indexing)
	Embedding []float32 `json:"embedding,omitempty"`

	// Parent symbol ID (for nested symbols like methods in classes)
	ParentID *string `json:"parent_id,omitempty"`

	// Additional metadata
	Metadata map[string]interface{} `json:"metadata,omitempty"`

	// Timestamps
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// Children symbols (populated when fetching with depth)
	Children []*CodeSymbol `json:"children,omitempty"`
}

CodeSymbol represents a parsed code symbol from source code

type GenericExtractor

type GenericExtractor struct {
	BaseExtractor
}

GenericExtractor is a fallback extractor that works with any language

func NewGenericExtractor

func NewGenericExtractor(config WalkerConfig) *GenericExtractor

NewGenericExtractor creates a new generic extractor

func (*GenericExtractor) ExtractSymbols

func (g *GenericExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts symbols using generic node type detection

func (*GenericExtractor) GetSymbolTypes

func (g *GenericExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the symbol types the generic extractor can find

type GoExtractor

type GoExtractor struct {
	BaseExtractor
}

GoExtractor extracts symbols from Go source code

func NewGoExtractor

func NewGoExtractor(config WalkerConfig) *GoExtractor

NewGoExtractor creates a new Go extractor

func (*GoExtractor) ExtractSymbols

func (g *GoExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Go source code

func (*GoExtractor) GetSymbolTypes

func (g *GoExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Go extractor can find

type IndexingJob

type IndexingJob struct {
	// Job identifier
	ID string `json:"id"`

	// Project being indexed
	ProjectID string `json:"project_id"`

	// Path to the project
	ProjectPath string `json:"project_path"`

	// Current status
	Status IndexingStatus `json:"status"`

	// Progress percentage (0-100)
	Progress float64 `json:"progress"`

	// File counts
	FilesTotal   int `json:"files_total"`
	FilesIndexed int `json:"files_indexed"`
	FilesFailed  int `json:"files_failed,omitempty"`

	// Non-fatal warnings collected during indexing (e.g. per-file parse failures)
	Warnings []string `json:"warnings,omitempty"`

	// Timing
	StartedAt   time.Time  `json:"started_at"`
	CompletedAt *time.Time `json:"completed_at,omitempty"`

	// Error message if failed
	Error *string `json:"error,omitempty"`
}

IndexingJob represents an async indexing job

type IndexingStatus

type IndexingStatus string

IndexingStatus represents the status of an indexing job

const (
	IndexingStatusPending    IndexingStatus = "pending"
	IndexingStatusInProgress IndexingStatus = "in_progress"
	IndexingStatusCompleted  IndexingStatus = "completed"
	IndexingStatusFailed     IndexingStatus = "failed"
	IndexingStatusCancelled  IndexingStatus = "cancelled"
)

type JavaExtractor

type JavaExtractor struct {
	BaseExtractor
}

JavaExtractor extracts symbols from Java source code

func NewJavaExtractor

func NewJavaExtractor(config WalkerConfig) *JavaExtractor

NewJavaExtractor creates a new Java extractor

func (*JavaExtractor) ExtractSymbols

func (j *JavaExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Java source code

func (*JavaExtractor) GetSymbolTypes

func (j *JavaExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Java extractor can find

type JavaScriptExtractor

type JavaScriptExtractor struct {
	BaseExtractor
}

JavaScriptExtractor extracts symbols from JavaScript source code

func NewJavaScriptExtractor

func NewJavaScriptExtractor(config WalkerConfig) *JavaScriptExtractor

NewJavaScriptExtractor creates a new JavaScript extractor

func (*JavaScriptExtractor) ExtractSymbols

func (j *JavaScriptExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from JavaScript source code

func (*JavaScriptExtractor) GetSymbolTypes

func (j *JavaScriptExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the JavaScript extractor can find

type KotlinExtractor

type KotlinExtractor struct {
	BaseExtractor
}

KotlinExtractor extracts symbols from Kotlin source code

func NewKotlinExtractor

func NewKotlinExtractor(config WalkerConfig) *KotlinExtractor

NewKotlinExtractor creates a new Kotlin extractor

func (*KotlinExtractor) ExtractSymbols

func (k *KotlinExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Kotlin source code

func (*KotlinExtractor) GetSymbolTypes

func (k *KotlinExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Kotlin extractor can find

type Language

type Language string

Language represents a supported programming language

const (
	LanguageGo         Language = "go"
	LanguageTypeScript Language = "typescript"
	LanguageJavaScript Language = "javascript"
	LanguagePHP        Language = "php"
	LanguageRust       Language = "rust"
	LanguageJava       Language = "java"
	LanguageKotlin     Language = "kotlin"
	LanguageSwift      Language = "swift"
	LanguageObjectiveC Language = "objc"
	LanguageC          Language = "c"
	LanguageCPP        Language = "cpp"
	LanguagePython     Language = "python"
	LanguageRuby       Language = "ruby"
	LanguageCSharp     Language = "csharp"
	LanguageLua        Language = "lua"
	LanguageMarkdown   Language = "markdown"
	LanguageSvelte     Language = "svelte"
	LanguageTOML       Language = "toml"
	LanguageVue        Language = "vue"
)

func DetectLanguage

func DetectLanguage(filePath string) (Language, bool)

DetectLanguage detects the language from a file path

func GetLanguageByExtension

func GetLanguageByExtension(ext string) (Language, bool)

GetLanguageByExtension returns the Language for a file extension (without dot)

func GetSupportedLanguages

func GetSupportedLanguages() []Language

GetSupportedLanguages returns all supported language identifiers

type LanguageInfo

type LanguageInfo struct {
	// Language identifier
	Language Language

	// Human-readable name
	Name string

	// File extensions (without dot)
	Extensions []string

	// Tree-sitter language getter
	Grammar func() *sitter.Language
}

LanguageInfo holds metadata about a supported language

func GetLanguageInfo

func GetLanguageInfo(lang Language) (LanguageInfo, bool)

GetLanguageInfo returns the LanguageInfo for a Language

type LuaExtractor

type LuaExtractor struct {
	BaseExtractor
}

LuaExtractor extracts symbols from Lua source code

func NewLuaExtractor

func NewLuaExtractor(config WalkerConfig) *LuaExtractor

NewLuaExtractor creates a new Lua extractor

func (*LuaExtractor) ExtractSymbols

func (l *LuaExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Lua source code

func (*LuaExtractor) GetSymbolTypes

func (l *LuaExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Lua extractor can find

type MarkdownExtractor

type MarkdownExtractor struct {
	BaseExtractor
}

MarkdownExtractor extracts symbols from Markdown source code

func NewMarkdownExtractor

func NewMarkdownExtractor(config WalkerConfig) *MarkdownExtractor

NewMarkdownExtractor creates a new Markdown extractor

func (*MarkdownExtractor) ExtractSymbols

func (m *MarkdownExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Markdown source code

func (*MarkdownExtractor) GetSymbolTypes

func (m *MarkdownExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Markdown extractor can find

type NodeIterator

type NodeIterator struct {
	// contains filtered or unexported fields
}

NodeIterator provides iteration over nodes in a tree

func NewNodeIterator

func NewNodeIterator(root *sitter.Node) *NodeIterator

NewNodeIterator creates a new iterator starting from the given node

func (*NodeIterator) Next

func (it *NodeIterator) Next() *sitter.Node

Next returns the next node in depth-first order, or nil if done

func (*NodeIterator) Reset

func (it *NodeIterator) Reset(root *sitter.Node)

Reset restarts the iterator from a new root

type PHPExtractor

type PHPExtractor struct {
	BaseExtractor
}

PHPExtractor extracts symbols from PHP source code

func NewPHPExtractor

func NewPHPExtractor(config WalkerConfig) *PHPExtractor

NewPHPExtractor creates a new PHP extractor

func (*PHPExtractor) ExtractSymbols

func (p *PHPExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from PHP source code

func (*PHPExtractor) GetSymbolTypes

func (p *PHPExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the PHP extractor can find

type ParseError

type ParseError struct {
	// Error message
	Message string `json:"message"`

	// Location
	Line   int `json:"line"`
	Column int `json:"column"`
}

ParseError represents a parsing error

type ParseResult

type ParseResult struct {
	// The file that was parsed
	FilePath string `json:"file_path"`

	// Detected language
	Language Language `json:"language"`

	// Extracted symbols
	Symbols []*CodeSymbol `json:"symbols"`

	// Parse errors (if any)
	Errors []ParseError `json:"errors,omitempty"`
}

ParseResult represents the result of parsing a source file

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is a thread-safe wrapper around tree-sitter parsers

func NewParser

func NewParser() *Parser

NewParser creates a new Parser instance

func (*Parser) Close

func (p *Parser) Close()

Close releases all parser resources

func (*Parser) Parse

func (p *Parser) Parse(ctx context.Context, sourceCode []byte, lang Language) (*sitter.Tree, error)

Parse parses source code with the specified language

func (*Parser) ParseDirectory

func (p *Parser) ParseDirectory(ctx context.Context, dirPath string) ([]*ParserResult, error)

ParseDirectory parses all supported files in a directory (non-recursive)

func (*Parser) ParseFile

func (p *Parser) ParseFile(ctx context.Context, filePath string) (*sitter.Tree, Language, error)

ParseFile parses a source file and returns the syntax tree

func (*Parser) ParseWithPreviousTree

func (p *Parser) ParseWithPreviousTree(ctx context.Context, sourceCode []byte, lang Language, oldTree *sitter.Tree) (*sitter.Tree, error)

ParseWithPreviousTree parses source code with incremental parsing support

type ParserResult

type ParserResult struct {
	// The parsed tree
	Tree *sitter.Tree

	// The detected language
	Language Language

	// The source code
	SourceCode []byte

	// File path
	FilePath string
}

ParseResult contains the result of parsing a source file

type PythonExtractor

type PythonExtractor struct {
	BaseExtractor
}

PythonExtractor extracts symbols from Python source code

func NewPythonExtractor

func NewPythonExtractor(config WalkerConfig) *PythonExtractor

NewPythonExtractor creates a new Python extractor

func (*PythonExtractor) ExtractSymbols

func (p *PythonExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Python source code

func (*PythonExtractor) GetSymbolTypes

func (p *PythonExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Python extractor can find

type RustExtractor

type RustExtractor struct {
	BaseExtractor
}

RustExtractor extracts symbols from Rust source code

func NewRustExtractor

func NewRustExtractor(config WalkerConfig) *RustExtractor

NewRustExtractor creates a new Rust extractor

func (*RustExtractor) ExtractSymbols

func (r *RustExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Rust source code

func (*RustExtractor) GetSymbolTypes

func (r *RustExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Rust extractor can find

type SemanticSearchQuery

type SemanticSearchQuery struct {
	// Project to search in
	ProjectID string `json:"project_id"`

	// Natural language query
	Query string `json:"query"`

	// Maximum results
	Limit int `json:"limit,omitempty"`

	// Filter by languages
	Languages []Language `json:"languages,omitempty"`

	// Filter by symbol types
	SymbolTypes []SymbolType `json:"symbol_types,omitempty"`
}

SemanticSearchQuery represents a semantic search query

type SemanticSearchResult

type SemanticSearchResult struct {
	// The matched symbol
	Symbol *CodeSymbol `json:"symbol"`

	// Similarity score (0-1)
	Score float64 `json:"score"`
}

SemanticSearchResult represents a result from semantic search

type SvelteExtractor

type SvelteExtractor struct {
	BaseExtractor
}

SvelteExtractor extracts symbols from Svelte source code

func NewSvelteExtractor

func NewSvelteExtractor(config WalkerConfig) *SvelteExtractor

NewSvelteExtractor creates a new Svelte extractor

func (*SvelteExtractor) ExtractSymbols

func (s *SvelteExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Svelte source code

func (*SvelteExtractor) GetSymbolTypes

func (s *SvelteExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Svelte extractor can find

type SwiftExtractor

type SwiftExtractor struct {
	BaseExtractor
}

SwiftExtractor extracts symbols from Swift source code

func NewSwiftExtractor

func NewSwiftExtractor(config WalkerConfig) *SwiftExtractor

NewSwiftExtractor creates a new Swift extractor

func (*SwiftExtractor) ExtractSymbols

func (s *SwiftExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Swift source code

func (*SwiftExtractor) GetSymbolTypes

func (s *SwiftExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Swift extractor can find

type SymbolExtractor

type SymbolExtractor interface {
	// Language returns the language this extractor handles
	Language() Language

	// ExtractSymbols extracts all symbols from a parsed tree
	ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

	// GetSymbolTypes returns the types of symbols this extractor can find
	GetSymbolTypes() []SymbolType
}

SymbolExtractor defines the interface for language-specific symbol extraction

type SymbolModifiers

type SymbolModifiers struct {
	Visibility Visibility `json:"visibility,omitempty"`
	Static     bool       `json:"static,omitempty"`
	Abstract   bool       `json:"abstract,omitempty"`
	Final      bool       `json:"final,omitempty"`
	Async      bool       `json:"async,omitempty"`
	Const      bool       `json:"const,omitempty"`
	Readonly   bool       `json:"readonly,omitempty"`
}

SymbolModifiers holds modifiers applicable to symbols

type SymbolQuery

type SymbolQuery struct {
	// Project to search in
	ProjectID string `json:"project_id"`

	// Name pattern (supports wildcards)
	NamePattern string `json:"name_pattern,omitempty"`

	// Name path pattern
	NamePathPattern string `json:"name_path_pattern,omitempty"`

	// Restrict to specific file or directory
	RelativePath string `json:"relative_path,omitempty"`

	// Include children up to this depth
	Depth int `json:"depth,omitempty"`

	// Include source code in results
	IncludeBody bool `json:"include_body,omitempty"`

	// Filter by symbol types
	IncludeTypes []SymbolType `json:"include_types,omitempty"`
	ExcludeTypes []SymbolType `json:"exclude_types,omitempty"`

	// Filter by languages
	Languages []Language `json:"languages,omitempty"`

	// Enable substring matching
	SubstringMatch bool `json:"substring_match,omitempty"`

	// Maximum results
	Limit int `json:"limit,omitempty"`
}

SymbolQuery represents search criteria for finding symbols

type SymbolType

type SymbolType string

SymbolType represents the type of a code symbol

const (
	SymbolTypeClass       SymbolType = "class"
	SymbolTypeStruct      SymbolType = "struct"
	SymbolTypeInterface   SymbolType = "interface"
	SymbolTypeTrait       SymbolType = "trait"
	SymbolTypeMethod      SymbolType = "method"
	SymbolTypeFunction    SymbolType = "function"
	SymbolTypeConstructor SymbolType = "constructor"
	SymbolTypeProperty    SymbolType = "property"
	SymbolTypeField       SymbolType = "field"
	SymbolTypeVariable    SymbolType = "variable"
	SymbolTypeConstant    SymbolType = "constant"
	SymbolTypeEnum        SymbolType = "enum"
	SymbolTypeEnumMember  SymbolType = "enum_member"
	SymbolTypeTypeAlias   SymbolType = "type_alias"
	SymbolTypeNamespace   SymbolType = "namespace"
	SymbolTypeModule      SymbolType = "module"
	SymbolTypePackage     SymbolType = "package"
)

type TOMLExtractor

type TOMLExtractor struct {
	BaseExtractor
}

TOMLExtractor extracts symbols from TOML source code

func NewTOMLExtractor

func NewTOMLExtractor(config WalkerConfig) *TOMLExtractor

NewTOMLExtractor creates a new TOML extractor

func (*TOMLExtractor) ExtractSymbols

func (t *TOMLExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from TOML source code

func (*TOMLExtractor) GetSymbolTypes

func (t *TOMLExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the TOML extractor can find

type TypeScriptExtractor

type TypeScriptExtractor struct {
	BaseExtractor
}

TypeScriptExtractor extracts symbols from TypeScript source code

func NewTypeScriptExtractor

func NewTypeScriptExtractor(config WalkerConfig) *TypeScriptExtractor

NewTypeScriptExtractor creates a new TypeScript extractor

func (*TypeScriptExtractor) ExtractSymbols

func (t *TypeScriptExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from TypeScript source code

func (*TypeScriptExtractor) GetSymbolTypes

func (t *TypeScriptExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the TypeScript extractor can find

type Visibility

type Visibility string

Visibility represents symbol visibility/access level

const (
	VisibilityPublic    Visibility = "public"
	VisibilityPrivate   Visibility = "private"
	VisibilityProtected Visibility = "protected"
	VisibilityInternal  Visibility = "internal"
	VisibilityPackage   Visibility = "package"
)

type VueExtractor

type VueExtractor struct {
	BaseExtractor
}

VueExtractor extracts symbols from Vue source code

func NewVueExtractor

func NewVueExtractor(config WalkerConfig) *VueExtractor

NewVueExtractor creates a new Vue extractor

func (*VueExtractor) ExtractSymbols

func (v *VueExtractor) ExtractSymbols(tree *sitter.Tree, sourceCode []byte, filePath string, projectID string) ([]*CodeSymbol, error)

ExtractSymbols extracts all symbols from Vue source code

func (*VueExtractor) GetSymbolTypes

func (v *VueExtractor) GetSymbolTypes() []SymbolType

GetSymbolTypes returns the types of symbols the Vue extractor can find

type WalkerConfig

type WalkerConfig struct {
	// IncludeSourceCode determines if source code is included in symbols
	IncludeSourceCode bool

	// MaxSymbolSize is the maximum size of source code to include (in bytes)
	MaxSymbolSize int

	// ExtractDocStrings determines if documentation comments are extracted
	ExtractDocStrings bool
}

WalkerConfig holds configuration for the AST walker

func DefaultWalkerConfig

func DefaultWalkerConfig() WalkerConfig

DefaultWalkerConfig returns sensible default configuration

Jump to

Keyboard shortcuts

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