@@ -350,54 +350,4 @@ constructor.
350350
351351---
352352
353- ## Code actions: shared edit-building helpers
354-
355- ** What to do.** Complementary to (and independent of) A34 in the
356- backlog:
357-
358- 1 . ** ` single_file_edit ` helper.** ` WorkspaceEdit ` for one file is
359- open-coded in ~ 35 files (~ 50 ` document_changes: None ` literals,
360- 8-12 lines each). Add
361- ` single_file_edit(uri, edits) -> WorkspaceEdit ` /
362- ` single_edit(uri, range, text) ` to ` code_actions/mod.rs ` and adopt.
363- 2 . ** Adopt ` util::byte_range_to_lsp_range ` .** The helper exists but is
364- used in code actions only by ` phpstan/add_throws.rs ` ; ~ 29 other
365- files hand-build ` Range { start: offset_to_position(..), end: .. } `
366- (183 ` offset_to_position ` calls).
367- 3 . ** Consolidate indent helpers.** Nine near-identical
368- line-indent-at-offset extractors and two copies of
369- ` detect_indent_unit ` across ` extract_function.rs ` ,
370- ` generate_property_hooks.rs ` , ` update_docblock.rs ` ,
371- ` convert_switch_to_match.rs ` , ` extract_constant.rs ` ,
372- ` phpstan/new_static.rs ` , ` implement_methods.rs ` . Provide
373- ` indent_of_line_at ` / ` indent_unit ` next to
374- ` detect_indent_from_members ` .
375- 4 . ** Unify the name-deduplication helpers.** ` deduplicate_name ` in
376- ` extract_variable.rs ` (checks a ` &[String] ` of in-scope names,
377- numeric suffix), ` deduplicate_constant_name ` in ` extract_constant.rs `
378- (same shape, ` _N ` suffix), and ` deduplicate_name ` in
379- ` extract_function.rs ` (scans sibling method names or ` function <name> `
380- patterns in the file) all solve "make this name unique." Back them
381- with one helper in ` code_actions/naming.rs ` that takes an
382- ` exists: impl Fn(&str) -> bool ` predicate and a suffix separator. (The
383- pure casing transforms — ` to_camel_case ` , ` snake_to_camel ` ,
384- ` to_pascal_case ` , ` string_to_screaming_snake ` , ` capitalise ` — already
385- live in ` code_actions/naming.rs ` .)
386- 5 . ** ` find_docblock_above_line ` helper.** At least three independent
387- copies (` phpstan/remove_throws.rs ` , ` phpstan/add_throws.rs ` ,
388- ` phpstan/add_iterable_type.rs ` ) locate the ` /** */ ` block above a
389- line; ` update_docblock.rs ` additionally owns a private docblock
390- line-model (` parse_docblock_lines ` /` rebuild_docblock ` ) that the
391- other handlers re-approximate. Extract a shared
392- ` code_actions/docblock_edit.rs ` .
393- 6 . ** Relocate PHPStan-specific logic out of ` code_actions/mod.rs ` **
394- (` expand_sibling_checked_exception_diags ` ,
395- ` clear_phpstan_diagnostics_after_resolve ` ) into ` phpstan/mod.rs ` .
396-
397- ** Why it matters.** Several new code actions are scheduled (A40, A41,
398- H4-H24, FX rules); each currently starts by copying this plumbing from
399- a neighbour, adding another divergent copy per action.
400-
401- ---
402-
403353
0 commit comments