rust-lang / rust-lang/rust-analyzer
`extract_variable` should be able to heuristically extract multiple occurences of the same expression
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
As mentioned in https://github.com/rust-analyzer/rust-analyzer/issues/7692#issuecomment-888356714_ it might be nice to have extract_variable lift out all occurences of the target expression in the current function and replace them with the new variable name.
Open question is what theres heuristics are exactly. For example this should keep in mind the places of these expressions to decide whether it would make sense to extract more than just the target, like expressions in function arguments where those parameters have the same name etc.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the extract_variable implementation and the discussion in issue #7692, especially the linked comment. Clarify the heuristics for selecting additional occurrences and related expressions, then define tests covering repeated expressions and function-argument contexts; done means the behavior is specified and validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100