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

Function rename_method_cross_file

src/rename/tests.rs:608–648  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

606
607#[tokio::test]
608async fn rename_method_cross_file() {
609 let backend = Backend::new_test();
610 let uri_a = Url::parse("file:///a.php").unwrap();
611 let uri_b = Url::parse("file:///b.php").unwrap();
612
613 let text_a = concat!(
614 "<?php\n",
615 "class Printer {\n",
616 " public function print(): void {}\n",
617 "}\n",
618 );
619
620 let text_b = concat!(
621 "<?php\n",
622 "function demo(): void {\n",
623 " $p = new Printer();\n",
624 " $p->print();\n",
625 "}\n",
626 );
627
628 open_file(&backend, &uri_a, text_a).await;
629 open_file(&backend, &uri_b, text_b).await;
630
631 // Rename from the call site in file b.
632 let edit = rename(&backend, &uri_b, 3, 9, "output").await;
633 assert!(edit.is_some());
634
635 let edit = edit.unwrap();
636 let edits_a = edits_for_uri(&edit, &uri_a);
637 let edits_b = edits_for_uri(&edit, &uri_b);
638
639 assert!(
640 !edits_a.is_empty(),
641 "Expected edits in file a (declaration)"
642 );
643 assert!(!edits_b.is_empty(), "Expected edits in file b (call site)");
644
645 for te in edits_a.iter().chain(edits_b.iter()) {
646 assert_eq!(te.new_text, "output");
647 }
648}
649
650// ─── Whitespace / No Symbol ─────────────────────────────────────────────────
651

Callers

nothing calls this directly

Calls 5

renameFunction · 0.85
edits_for_uriFunction · 0.85
iterMethod · 0.80
open_fileFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected