Trait for language-specific AST entity extraction. Each language parser implements this trait, providing entity extraction (functions, classes, interfaces, etc.) and optionally reference extraction (function calls, variable usages). # Implementation Notes - Parsers are **stateful** (they hold a `tree_sitter::Parser` instance). Create one per thread or per request, not globally. - `extract()` sh
| 182 | /// - Entity names should be the *simple* name (e.g., `greet`, not `module.greet`). |
| 183 | /// - Line numbers are 1-based (matching editor conventions). |
| 184 | pub trait LanguageParser: Send { |
| 185 | /// The language this parser handles. |
| 186 | fn language(&self) -> Language; |
| 187 | |
| 188 | /// Extract AST entities (functions, classes, etc.) from source code. |
| 189 | /// |
| 190 | /// # Arguments |
| 191 | /// |
| 192 | /// * `source` - The source code text. |
| 193 | /// * `file_path` - The file path (for Entity.file field). |
| 194 | /// |
| 195 | /// # Returns |
| 196 | /// |
| 197 | /// A list of entities found in the source code. |
| 198 | fn extract(&mut self, source: &str, file_path: &str) -> Vec<Entity>; |
| 199 | |
| 200 | /// Extract references (function calls, variable usages) from source code. |
| 201 | /// |
| 202 | /// The default implementation returns an empty list. Languages that |
| 203 | /// support reference extraction should override this. |
| 204 | /// |
| 205 | /// # Arguments |
| 206 | /// |
| 207 | /// * `source` - The source code text. |
| 208 | /// * `file_path` - The file path (for Reference.file field). |
| 209 | /// |
| 210 | /// # Returns |
| 211 | /// |
| 212 | /// A list of references found in the source code. |
| 213 | fn extract_references(&mut self, source: &str, file_path: &str) -> Vec<Reference> { |
| 214 | let _ = (source, file_path); |
| 215 | Vec::new() |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // ═══════════════════════════════════════════════════════════════════════ |
| 220 | // ParserRegistry — unified entry point for all languages |
nothing calls this directly
no outgoing calls
no test coverage detected