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

Method analyze_source

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

Shared source context for search, callers and review. Qualified targets, receivers and lexical owners are retained instead of flattened names.

(
        &mut self,
        path: &str,
        source: &str,
    )

Source from the content-addressed store, hash-verified

304 /// Shared source context for search, callers and review. Qualified targets,
305 /// receivers and lexical owners are retained instead of flattened names.
306 pub fn analyze_source(
307 &mut self,
308 path: &str,
309 source: &str,
310 ) -> Result<crate::source::SourceAnalysis, String> {
311 if source.len() > crate::MAX_SOURCE_BYTES || source.contains('\0') {
312 return Err("Semantic source exceeds byte limit or is binary".into());
313 }
314 let language = Language::detect(path).ok_or("Unsupported semantic source language")?;
315 let parser = self
316 .parsers
317 .get_mut(&language)
318 .ok_or("No registered semantic parser")?;
319 let tree = parser
320 .parse_tree(source)
321 .ok_or("No registered semantic syntax tree")?;
322 crate::source::SourceAnalysis::from_tree(path, source, language, &tree, || {
323 parser.extract_from_tree(&tree, source, path)
324 })
325 }
326 /// Create a new registry with all supported language parsers.
327 pub fn new() -> Self {
328 let mut parsers: HashMap<Language, Box<dyn LanguageParser>> = HashMap::new();

Calls 5

get_mutMethod · 0.80
lenMethod · 0.45
containsMethod · 0.45
parse_treeMethod · 0.45
extract_from_treeMethod · 0.45