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

Function merge_data_class_names

src/completion/builder.rs:685–703  ·  view source on GitHub ↗

Merge the class name from a new item's `data` into the existing item's `data.extra_class_names` so that `completionItem/resolve` can iterate all union branches when building hover documentation.

(existing: &mut CompletionItem, new_item: &CompletionItem)

Source from the content-addressed store, hash-verified

683/// `data.extra_class_names` so that `completionItem/resolve` can iterate
684/// all union branches when building hover documentation.
685fn merge_data_class_names(existing: &mut CompletionItem, new_item: &CompletionItem) {
686 let (Some(existing_data), Some(new_data)) = (&existing.data, &new_item.data) else {
687 return;
688 };
689 let (Ok(mut ed), Ok(nd)) = (
690 serde_json::from_value::<CompletionItemData>(existing_data.clone()),
691 serde_json::from_value::<CompletionItemData>(new_data.clone()),
692 ) else {
693 return;
694 };
695 // Skip if the class name is already recorded.
696 if ed.class_name == nd.class_name || ed.extra_class_names.contains(&nd.class_name) {
697 return;
698 }
699 ed.extra_class_names.push(nd.class_name.clone());
700 if let Ok(v) = serde_json::to_value(&ed) {
701 existing.data = Some(v);
702 }
703}
704
705/// Extract the class name(s) from a `CompletionItem`'s `data` field.
706///

Callers 1

Calls 3

cloneMethod · 0.80
containsMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected