62159
Sy
symb / files
symb / internal / treesitter / symbols.go
1.1 KB
1// Package treesitter provides tree-sitter based code parsing for structural 2// symbol extraction. Used to build project-wide context for LLM awareness. 3package treesitter 4 5// SymbolKind classifies extracted symbols. 6type SymbolKind int 7 8const ( 9 KindPackage SymbolKind = iota 10 KindImport 11 KindFunction 12 KindMethod 13 KindType 14 KindStruct 15 KindInterface 16 KindConst 17 KindVar 18) 19 20// Symbol represents a single extracted code symbol. 21type Symbol struct { 22 Name string 23 Kind SymbolKind 24 Signature string // e.g. "func (p *Proxy) CallTool(ctx context.Context, ...)" 25 StartLine int // 1-indexed 26 EndLine int // 1-indexed 27 Receiver string // method receiver type, empty for functions 28 Children []Symbol 29} 30 31// KindString returns a short label for the symbol kind. 32func (k SymbolKind) String() string { 33 switch k { 34 case KindPackage: 35 return "pkg" 36 case KindImport: 37 return "import" 38 case KindFunction: 39 return "func" 40 case KindMethod: 41 return "method" 42 case KindType: 43 return "type" 44 case KindStruct: 45 return "struct" 46 case KindInterface: 47 return "interface" 48 case KindConst: 49 return "const" 50 case KindVar: 51 return "var" 52 default: 53 return "unknown" 54 } 55}