Add code actions for unknown modules and structs#891
Open
sheldak wants to merge 1 commit intoelixir-lsp:masterfrom
Open
Add code actions for unknown modules and structs#891sheldak wants to merge 1 commit intoelixir-lsp:masterfrom
sheldak wants to merge 1 commit intoelixir-lsp:masterfrom
Conversation
Contributor
Author
|
@lukaszsamson Could you give me some feedback on that feature? |
Collaborator
|
Sorry this is taking time but work on experimental server has stalled. I'm thinking of removing it. What do you think about migrating this PR back to original server code? There was already a PR adding some code action (now reverted due to many problems in implementation) #718 |
Contributor
Author
|
@lukaszsamson I see. I can definitely move this PR to the original code. However, I think many additional helpers introduced in the experimental server were very useful for working on AST. What about starting with migrating the existing code actions with all that helpers to the original server before introducing this new code action? |
Collaborator
|
Sure, we should salvage the good stuff |
Collaborator
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I propose another two code actions that can be applied when we get either:
Replacing modules
The first code action proposes replacing an unknown module with its full name. For example:
will be replaced with
if we have module
ElixirLS.LanguageServer.Fixtures.ExampleStructavailable. Similarlycan be replaced with
if
ElixirLS.LanguageServer.Fixtures.ExampleDefaultArgsis available.Adding an alias
The second code action adds an alias that is required to make the code work. For example:
will be replaced with
and
will be replaced with
Notes
ElixirSense.Core.Metadata.get_position_to_insert_alias/2function which has two limitations that may affect the usability of the code action:@moduledocwhich may not be a perfect place