Collect `name:` argument completion items inside function/method call parentheses. Returns an empty `Vec` when the cursor is not in a named-argument context or when no parameters could be resolved. The items are meant to be **merged** into whatever other completion strategy wins — named args are always valid alongside normal completions.
(
&self,
uri: &str,
content: &str,
position: Position,
ctx: &FileContext,
)
| 739 | /// meant to be **merged** into whatever other completion strategy |
| 740 | /// wins — named args are always valid alongside normal completions. |
| 741 | fn collect_named_arg_items( |
| 742 | &self, |
| 743 | uri: &str, |
| 744 | content: &str, |
| 745 | position: Position, |
| 746 | ctx: &FileContext, |
| 747 | ) -> Vec<CompletionItem> { |
| 748 | // ── Primary path: AST-based detection via symbol map ──────── |
| 749 | // The symbol map's `CallSite` data handles chains, nesting, |
| 750 | // and strings correctly. Fall back to text scanning when the |
| 751 | // AST has no hit (typically because the parser couldn't recover |
| 752 | // from incomplete code). |
| 753 | let na_ctx = match self |
| 754 | .detect_named_arg_from_symbol_map(uri, content, position) |
| 755 | .or_else(|| crate::completion::named_args::detect_named_arg_context(content, position)) |
| 756 | { |
| 757 | Some(ctx) => ctx, |
| 758 | None => return Vec::new(), |
| 759 | }; |
| 760 | |
| 761 | let mut params = self.resolve_named_arg_params(&na_ctx, content, position, ctx); |
| 762 | |
| 763 | // If resolution failed, the parser may have choked on |
| 764 | // incomplete code (e.g. an unclosed `(`). Patch the |
| 765 | // content by inserting `);` at the cursor position so |
| 766 | // the class body becomes syntactically valid, then |
| 767 | // re-parse and retry resolution. |
| 768 | if params.is_empty() { |
| 769 | let patched = Self::patch_content_at_cursor(content, position); |
| 770 | if patched != content { |
| 771 | let patched_classes: Vec<Arc<crate::types::ClassInfo>> = |
| 772 | self.parse_php(&patched).into_iter().map(Arc::new).collect(); |
| 773 | if !patched_classes.is_empty() { |
| 774 | let patched_ctx = FileContext { |
| 775 | classes: patched_classes, |
| 776 | use_map: ctx.use_map.clone(), |
| 777 | namespace: ctx.namespace.clone(), |
| 778 | resolved_names: ctx.resolved_names.clone(), |
| 779 | }; |
| 780 | params = |
| 781 | self.resolve_named_arg_params(&na_ctx, &patched, position, &patched_ctx); |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | crate::completion::named_args::build_named_arg_completions(&na_ctx, ¶ms) |
| 787 | } |
| 788 | |
| 789 | /// Detect a named-argument context using precomputed [`CallSite`] data |
| 790 | /// from the symbol map. |
no test coverage detected