Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Code Action: Remove unused aliases#748

Merged
scohen merged 3 commits into
mainfrom
remove-unused-alias
May 31, 2024
Merged

Code Action: Remove unused aliases#748
scohen merged 3 commits into
mainfrom
remove-unused-alias

Conversation

@scohen

@scohen scohen commented May 22, 2024

Copy link
Copy Markdown
Collaborator

This code action removes any unused aliases. It handles both single aliases where it deletes the entire line up to the next line, and multiple aliases, where it deletes the single alias in the list, handling edge cases when it deletes both the last entry in the list, deleting the previous line's comma and when there's only one entry in the list when it deletes the whole alias.

The approach here is much more complicated than I wanted, I described the reasons why it's that way in the module's documentation, hopefully, we can get a fix from sourceror soon and improve this.

@scohen scohen requested review from scottming and zachallaun May 22, 2024 02:07
Base automatically changed from add-alias-code-action to main May 23, 2024 15:42
@scohen scohen force-pushed the remove-unused-alias branch from 93834ac to 88744c5 Compare May 23, 2024 15:43
@scohen scohen force-pushed the remove-unused-alias branch from 2a8ed99 to fe7f9aa Compare May 24, 2024 20:51
@scohen scohen requested a review from zachallaun May 24, 2024 20:52
@scohen scohen force-pushed the remove-unused-alias branch from 8fb9622 to 4538142 Compare May 25, 2024 00:03
scohen added 3 commits May 30, 2024 10:45
This code action removes any unused aliases. It handles both single
aliases where it deletes the entire line up to the next line, and
multiple aliases, where it deletes the single alias in the list,
handling edge cases when it deletes both the last entry in the list,
deleting the previous line's comma and when there's only one entry in
the list when it deletes the whole alias.

The approach here is much more complicated than I wanted, I described
the reasons why it's that way in the module's documentation,
hopefully, we can get a fix from sourceror soon and improve this.
  * Handled removing aliases defined with as:
  * Only remove aliases on the line that contains the cursor
@scohen scohen force-pushed the remove-unused-alias branch from 4538142 to e11b299 Compare May 30, 2024 17:45
@scohen scohen merged commit cc5c2f9 into main May 31, 2024
@scohen scohen deleted the remove-unused-alias branch May 31, 2024 23:39
scottming pushed a commit to scottming/lexical that referenced this pull request Jun 1, 2024
* Code Action: Remove unused aliases

This code action removes any unused aliases. It handles both single
aliases where it deletes the entire line up to the next line, and
multiple aliases, where it deletes the single alias in the list,
handling edge cases when it deletes both the last entry in the list,
deleting the previous line's comma and when there's only one entry in
the list when it deletes the whole alias.

The approach here is much more complicated than I wanted, I described
the reasons why it's that way in the module's documentation,
hopefully, we can get a fix from sourceror soon and improve this.

* made Ast.contains_position? inclusive, like range, and switched to it
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants