MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / LanguageParser

Interface LanguageParser

atomic-semantic/src/parsers/mod.rs:184–217  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

182/// - Entity names should be the *simple* name (e.g., `greet`, not `module.greet`).
183/// - Line numbers are 1-based (matching editor conventions).
184pub 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

Callers

nothing calls this directly

Implementers 7

rust.rsatomic-semantic/src/parsers/rust.rs
java.rsatomic-semantic/src/parsers/java.rs
swift.rsatomic-semantic/src/parsers/swift.rs
python.rsatomic-semantic/src/parsers/python.rs
cpp.rsatomic-semantic/src/parsers/cpp.rs
go.rsatomic-semantic/src/parsers/go.rs
typescript.rsatomic-semantic/src/parsers/typescript

Calls

no outgoing calls

Tested by

no test coverage detected