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

Method resolve

atomic-semantic/src/relationships.rs:374–621  ·  view source on GitHub ↗
(
        &self,
        file: &SourceAnalysis,
        call: &CallSite,
        before: Option<&Self>,
        check_access: bool,
    )

Source from the content-addressed store, hash-verified

372 }
373
374 fn resolve(
375 &self,
376 file: &SourceAnalysis,
377 call: &CallSite,
378 before: Option<&Self>,
379 check_access: bool,
380 ) -> Option<(String, String)> {
381 let caller = self.symbol(&call.caller, None)?;
382 if !matches!(
383 file.language,
384 Language::Rust | Language::TypeScript | Language::Tsx
385 ) && (call.receiver.is_some() || caller.owner.is_some())
386 {
387 return None;
388 }
389 let head = call.target.first()?;
390 // Known lexical receiver, not a global lookup for a common method name.
391 if let Some(receiver) = &call.receiver {
392 let owner = if matches!(receiver.as_str(), "self" | "this") {
393 caller.owner.as_ref()
394 } else {
395 caller.parameter_types.get(receiver)
396 };
397 if let Some(owner) = owner {
398 let name = call.target.last()?;
399 let candidates: Vec<_> = self
400 .symbols
401 .values()
402 .filter(|symbol| {
403 symbol.location.path == file.path
404 && symbol.owner.as_ref() == Some(owner)
405 && symbol.entity.name == *name
406 && symbol.module_scope == caller.module_scope
407 })
408 .collect();
409 if candidates.len() == 1 {
410 if check_access
411 && candidates[0].member_private
412 && caller.owner != candidates[0].owner
413 {
414 return None;
415 }
416 return Some((
417 candidates[0].id.clone(),
418 "AST lexical/declared receiver type and unique owned declaration".into(),
419 ));
420 }
421 return None;
422 }
423 }
424 if caller.shadows.contains(head)
425 || file
426 .globals
427 .get(&call.scope)
428 .is_some_and(|names| names.contains(head))
429 {
430 return None;
431 }

Callers 1

bind_callsMethod · 0.45

Calls 15

script_candidatesFunction · 0.85
symbolMethod · 0.80
as_refMethod · 0.80
lastMethod · 0.80
extendMethod · 0.80
is_noneMethod · 0.80
skipMethod · 0.80
contains_keyMethod · 0.80
getMethod · 0.65
clearMethod · 0.65
removeMethod · 0.65
collectMethod · 0.45

Tested by

no test coverage detected