Skip to content

fix(rename): scope member renames to resolved declarations#160

Open
calebdw wants to merge 1 commit into
PHPantom-dev:mainfrom
calebdw:calebdw/push-zuunqtysxumu
Open

fix(rename): scope member renames to resolved declarations#160
calebdw wants to merge 1 commit into
PHPantom-dev:mainfrom
calebdw:calebdw/push-zuunqtysxumu

Conversation

@calebdw

@calebdw calebdw commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Problem

Renaming a method was too broad.

If you renamed a method like recalculate() on one class, the server could also rename other recalculate() methods elsewhere in the codebase, including unrelated classes. This was especially bad for private methods, where the safe scope should be very narrow.

The root issue was that rename reused the same conservative matching used by Find References. That behavior is acceptable for search results, where unresolved member calls can be included as a fallback, but it is not safe for workspace edits.

There was also a second scoping problem around inheritance: when renaming a concrete implementation method, hierarchy expansion could walk up to an interface or parent class and then back down into sibling implementations that should not have been touched.

Fix

This PR makes member rename stricter than Find References:

  • rename now uses a dedicated member-reference path
  • unresolved same-name member calls are excluded from rename edits
  • declaration edits are scoped to the declaring branch of the hierarchy
  • descendant expansion starts from the actual target declaration instead of fanning out through ancestor interfaces

This means:

  • renaming a private method only updates that method and its real usages
  • renaming an implementation method does not rename sibling implementations
  • renaming a parent or interface declaration still updates valid inherited and implemented usages

Tests

Added regression coverage for:

  • private method rename staying scoped
  • cross-file private listener rename cases
  • unrelated classes with the same method name
  • interface declaration renames updating implementors
  • implementation renames not leaking to sibling implementors
  • child override renames staying on the child branch
  • parent renames still updating overrides and subclass call sites

@calebdw calebdw force-pushed the calebdw/push-zuunqtysxumu branch 2 times, most recently from 5e595fc to 428a9a3 Compare June 18, 2026 15:55
@calebdw calebdw force-pushed the calebdw/push-zuunqtysxumu branch from 349e049 to 6ec2b45 Compare June 18, 2026 16:45
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 98.49624% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/references/mod.rs 98.48% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants