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

Function rename_variable_in_function

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

Source from the content-addressed store, hash-verified

101
102#[tokio::test]
103async fn rename_variable_in_function() {
104 let backend = Backend::new_test();
105 let uri = Url::parse("file:///test.php").unwrap();
106 let text = concat!(
107 "<?php\n",
108 "function demo(): void {\n",
109 " $user = new User();\n",
110 " $user->name = 'Alice';\n",
111 " echo $user->name;\n",
112 "}\n",
113 );
114
115 open_file(&backend, &uri, text).await;
116
117 // Rename $user on line 2 (the assignment)
118 let edit = rename(&backend, &uri, 2, 5, "$person").await;
119 assert!(
120 edit.is_some(),
121 "Expected a workspace edit for variable rename"
122 );
123
124 let edit = edit.unwrap();
125 let file_edits = edits_for_uri(&edit, &uri);
126 assert!(
127 file_edits.len() >= 3,
128 "Expected at least 3 edits for $user (decl + 2 usages), got {}",
129 file_edits.len()
130 );
131
132 // All edits should use the new name with `$`.
133 for te in &file_edits {
134 assert_eq!(te.new_text, "$person");
135 }
136}
137
138#[tokio::test]
139async fn rename_variable_without_dollar_prefix() {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected