Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Action: Remove unused aliases #748

Merged
merged 3 commits into from
May 31, 2024
Merged

Code Action: Remove unused aliases #748

merged 3 commits into from
May 31, 2024

Conversation

scohen
Copy link
Collaborator

@scohen scohen commented May 22, 2024

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 zachallaun and scottming 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
9 checks passed
@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 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