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

Method handle_code_action

src/code_actions/mod.rs:167–236  ·  view source on GitHub ↗

Handle a `textDocument/codeAction` request. Returns a list of code actions applicable at the given range. Expensive actions return a lightweight stub with a [`CodeActionData`] `data` field and no `edit`; the edit is computed lazily in [`resolve_code_action`](Self::resolve_code_action).

(
        &self,
        uri: &str,
        content: &str,
        params: &CodeActionParams,
    )

Source from the content-addressed store, hash-verified

165 /// `data` field and no `edit`; the edit is computed lazily in
166 /// [`resolve_code_action`](Self::resolve_code_action).
167 pub fn handle_code_action(
168 &self,
169 uri: &str,
170 content: &str,
171 params: &CodeActionParams,
172 ) -> Vec<CodeActionOrCommand> {
173 let mut actions = Vec::new();
174
175 // ── Import class ────────────────────────────────────────────────
176 self.collect_import_class_actions(uri, content, params, &mut actions);
177
178 // ── Replace FQCN with import ────────────────────────────────────
179 self.collect_replace_fqcn_actions(uri, content, params, &mut actions);
180
181 // ── Import all missing classes (bulk) ───────────────────────────
182 self.collect_import_all_classes_action(uri, content, params, &mut actions);
183
184 // ── Remove unused imports ───────────────────────────────────────
185 self.collect_remove_unused_import_actions(uri, content, params, &mut actions);
186
187 // ── Implement missing methods ───────────────────────────────────
188 self.collect_implement_methods_actions(uri, content, params, &mut actions);
189
190 // ── Replace deprecated call ─────────────────────────────────────
191 self.collect_replace_deprecated_actions(uri, content, params, &mut actions);
192
193 // ── PHPStan-specific quickfixes (deferred) ──────────────────────
194 self.collect_phpstan_actions(uri, content, params, &mut actions);
195
196 // ── Mago quick-fix code actions ─────────────────────────────────
197 self.collect_mago_fix_actions(uri, content, params, &mut actions);
198
199 // ── Change visibility ───────────────────────────────────────────
200 self.collect_change_visibility_actions(uri, content, params, &mut actions);
201
202 // ── Update docblock to match signature ──────────────────────────
203 self.collect_update_docblock_actions(uri, content, params, &mut actions);
204
205 // ── Promote constructor parameter ───────────────────────────────────
206 self.collect_promote_constructor_param_actions(uri, content, params, &mut actions);
207
208 // ── Generate constructor ────────────────────────────────────────────
209 self.collect_generate_constructor_actions(uri, content, params, &mut actions);
210
211 // ── Generate getter/setter ──────────────────────────────────────────
212 self.collect_generate_getter_setter_actions(uri, content, params, &mut actions);
213
214 // ── Generate property hooks (PHP 8.4+) ─────────────────────────────
215 self.collect_generate_property_hook_actions(uri, content, params, &mut actions);
216
217 // ── Extract constant (deferred) ─────────────────────────────────
218 self.collect_extract_constant_actions(uri, content, params, &mut actions);
219
220 // ── Extract variable (deferred) ─────────────────────────────────
221 self.collect_extract_variable_actions(uri, content, params, &mut actions);
222
223 // ── Extract function / method (deferred) ────────────────────────
224 self.collect_extract_function_actions(uri, content, params, &mut actions);