-
-
Notifications
You must be signed in to change notification settings - Fork 43
[feat] integrate refactorex #5
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
Conversation
scohen
left a comment
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.
Refactorex adds capability for refactorings, but these need to be reported on boot.
Currently, the supported refactorings are listed in apps/server/lib/lexical/server/state.ex in a module attribute. I believe this needs to be updated.
@supported_code_actions [
:quick_fix,
:source_organize_imports
]
apps/remote_control/lib/lexical/remote_control/code_action/handlers/refactorex.ex
Outdated
Show resolved
Hide resolved
apps/remote_control/lib/lexical/remote_control/code_action/handlers/refactorex.ex
Outdated
Show resolved
Hide resolved
apps/remote_control/lib/lexical/remote_control/code_action/handlers/refactorex.ex
Outdated
Show resolved
Hide resolved
apps/remote_control/lib/lexical/remote_control/code_action/handlers/refactorex.ex
Outdated
Show resolved
Hide resolved
It kind of is. There was a pretty strong desire to keep LSP concepts out of the injected app. I'm not going to die on that hill, but having our own way of handling things internally is nice for contributors, though since they come in as a transitive dep, maybe it's not a big deal. |
This is great, I should have expressed that the whole design of remote_control is so that we can bring in any dependencies we want. |
Co-authored-by: Steve Cohen <scohen@scohen.org>
They work without it, I think that is mostly for reference, but I'll add them, no problem!
Absolutely. The GenLSP usage on Refactorex is for it working in its own, since only the refactorings are being used, I also would like to remove this dependency is the near future. Can we move along and refactor this later? Besides all that, how do you think we should move forward? keep the refactorings (edits in the ASTs) apart from the LS and use a combination of it and the features from the LS for some specific refactors or bring all of them in and have them only here? I think #2 is more powerful/easier for the future, but #1 could be cool for other projects to also use them. |
Of course.
My bias is for power and ease of contributions, which I think is #2, and I suspect that involves deeper integration with things like the AST modules that are defined in Expert's |
|
Note: I tried this branch and saw the same errors coming out of the formatter. |
Not explicitly. I use Sourceror.to_string, which I think uses Elixir.Code that might use the project formatter. What do you think is missing for this branch to be merged? |
apps/remote_control/lib/lexical/remote_control/code_action/handlers/refactorex.ex
Outdated
Show resolved
Hide resolved
apps/remote_control/lib/lexical/remote_control/code_action/handlers/add_alias.ex
Outdated
Show resolved
Hide resolved
apps/remote_control/lib/lexical/remote_control/code_action/handlers/organize_aliases.ex
Outdated
Show resolved
Hide resolved
apps/remote_control/test/lexical/remote_control/code_action/handlers/refactorex_test.exs
Show resolved
Hide resolved
A colleague found a fun edge case. He added three new empty files to a project, and Expert wouldn't start. This is because of a divide by zero error when there are no bytes to index, which causes progress updates to fail (indexing completed successfully). This fix checks for this condition and no-ops if there's nothing to index.
This reverts commit 389afbba063341ccde90bad72d0aa1246c9c3a5a.
After a lot of consideration, I've decided to initially bring Refactorex as a dependency to the project. That way, I was able to quickly integrate all the refactorings I've built last year at once, which will gain us some time to incorporate them one by one in the near future. The code action handler behaviour is pretty similar to the controller I had on Refactorex.
The downside of this approach is that GenLSP as also brought as a dependency to remote control. I've tried to avoid this by turning it into an optional dependency on Refactorex, but the lib couldn't compile after that. I hope that is not such a big problem though.
Two things I've noticed and would like to address are that:
I've commented a few formatter options because they were bugging the refactorings (still don't fully understand why, but I believe converting an AST to string uses the project formatter and the injected remote_control doesn't have common, proto, etc as dependencies). I've also commented two tests that were broken in main, but I can fix them if they are important tests :)
From my testing, all refactorings from Refactorex are indeed working, so I think we can start planning our next steps.