MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / resolve_function_name

Method resolve_function_name

src/resolution.rs:784–810  ·  view source on GitHub ↗

Resolve a function name using use-map and namespace context. Builds a list of candidate names (exact name, use-map resolved, namespace-qualified) and tries each via `find_or_load_function`. This is the single canonical implementation of the "function_loader" logic used by both the completion handler and definition resolver.

(
        &self,
        name: &str,
        file_use_map: &HashMap<String, String>,
        file_namespace: &Option<String>,
    )

Source from the content-addressed store, hash-verified

782 /// This is the single canonical implementation of the "function_loader"
783 /// logic used by both the completion handler and definition resolver.
784 pub(crate) fn resolve_function_name(
785 &self,
786 name: &str,
787 file_use_map: &HashMap<String, String>,
788 file_namespace: &Option<String>,
789 ) -> Option<FunctionInfo> {
790 // Build candidate names to try: exact name, use-map
791 // resolved name, and namespace-qualified name.
792 let mut candidates: Vec<&str> = vec![name];
793
794 let use_resolved: Option<String> = file_use_map.get(name).cloned();
795 if let Some(ref fqn) = use_resolved {
796 candidates.push(fqn.as_str());
797 }
798
799 let ns_qualified: Option<String> = file_namespace
800 .as_ref()
801 .map(|ns| format!("{}\\{}", ns, name));
802 if let Some(ref nq) = ns_qualified {
803 candidates.push(nq.as_str());
804 }
805
806 // Unified lookup: checks global_functions first, then
807 // falls back to embedded PHP stubs (parsed lazily and
808 // cached for future lookups).
809 self.find_or_load_function(&candidates)
810 }
811
812 // ─── Loader Closure Factories ───────────────────────────────────────
813

Calls 5

pushMethod · 0.80
as_strMethod · 0.80
find_or_load_functionMethod · 0.80
getMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected