-
Notifications
You must be signed in to change notification settings - Fork 41
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
Rename refactoring capablities v1 #196
Conversation
getUnqualActiveModules :: State -> Maybe String -> Array String | ||
getUnqualActiveModules state ident = getModules include state | ||
where | ||
include (Module { qualifier: Just _ }) = false | ||
include (Module { importType: Explicit idents }) = maybe false | ||
(\x -> x `elem` idents || ("(" <> x <> ")") `elem` idents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the ()
check is related to operators or suchlike, why is this being changed? Is there a specific case that seems to be handled incorrectly?
Regarding the constructor import comment, that is something that will be addressed shortly when I revive the changes for recent purs
versions, where mostly this code should be less required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right! Mia culpa. Have fixed it. I changed it when I was dealing with this problem of finding Type vs Constructor with the same name and I forgot about operators here (that is why we need more dev comments in the code explaining such things and/or tests -).
What do you mean by "will be addressed shortly", is there a PR or something that is going to deal with it in the compiler?
The compiler change is to allow filtering by import lists, so (when looking
for a specific ident) this code shouldn't be needed. And for not specific
ident it doesn't matter so much anyway.
That is landed already but the LSP changes are somewhere on machine and
stale - will try dig that up this week
…On Mon, 22 May 2023, 13:53 Alex, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/IdePurescript/Modules.purs
<#196 (comment)>
:
> getUnqualActiveModules :: State -> Maybe String -> Array String
getUnqualActiveModules state ident = getModules include state
where
include (Module { qualifier: Just _ }) = false
- include (Module { importType: Explicit idents }) = maybe false
- (\x -> x `elem` idents || ("(" <> x <> ")") `elem` idents)
Yes, you are right! Mia culpa. Have fixed it. I changed it when was
dealting with this problem of finding Type vs Constructor with the same
name and didn't think about operators (that is why we need more dev
comments in the code explaining such things -).
What do you mean by "will be addressed shortly", is there a PR or
something that is going to deal with it in the compiler?
—
Reply to this email directly, view it on GitHub
<#196 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVEPSYGBOLPWFM653K5WZ3XHOR3FANCNFSM6AAAAAAYJFRNUU>
.
You are receiving this because you commented.Message ID:
***@***.***
com>
|
Right, I too was working on this problem in finding references. Currently, in the rename refactor logic, I do the following: get all definitions for a target Another solution (that I tried to implement, but not finished yet) would be to determine on LS side if the target I wonder how you have dealt with the issue. |
@nwolverson Have you checked this one? |
This is still blocked on the changes I referenced before, it turns out there was some remaining work to be done there, which I started but have not finished. |
Right, sorry for the delay, can you look at reconciling this with main now. The main change I have is that
|
783bd18
to
f46acc7
Compare
You may check! |
Thanks, checking it out now |
I've not really looked into the API, what's the difference between Is it normal to rename invalid identifiers successfully and the user asking for a stupid thing gets a stupid result and can hit undo? Quick test with the JS language suggests so. After a quick play this feels pretty great! |
I don't get the particular scenario, can you elaborate? There where cases when may rename work strange, though I didn't encounter something that lead to really invalid code (at least I was able to undo it), it is probably due to that purs ide works only with valid compiled code, and I know that rename refactoring is valid and safe to do on compiled and saved modules. I think particular bad/strange case should be gathered and addressed if possible (in future). |
This PR adds rename refactoring capabilities to LS. It's supposed to support renaming of all kinds of exported identifiers (potentially even type classes with members 🤪), though due to the purs ide usage API issues it is limited when used with the current compiler version. Anyway it is still capable of renaming value/function identifiers and type constructors, though types and operators can not be renamed.
I actually have ready updates for the compiler to fix those issues with the usage API.
Tests are in test\Rename.purs - all tests pass only with the updated compiler version with usages api fixed.
This doesn't currently support renaming of local/private identifiers.
This PR is based on #194 (tidy formatting PR). All the changes referred to refactoring are in the single latest commit (yet).