-
Notifications
You must be signed in to change notification settings - Fork 136
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
Add Code Action / Quick Fix to remove unused include #1202
Closed
Labels
Comments
rahulraina7
added a commit
to rahulraina7/erlang_ls
that referenced
this issue
Feb 25, 2022
rahulraina7
added a commit
to rahulraina7/erlang_ls
that referenced
this issue
Feb 25, 2022
Add Fix for erlang-ls#1202 remove unused include
robertoaloi
pushed a commit
that referenced
this issue
Feb 28, 2022
* Add Fix for #1202 remove unused include * Fixing lint line length * Fixing failing tests * Fixing Var name * Update diagnostic type spec * Update diagnostic type spec * Fixing dialyzer errors
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
One of the core features of Erlang LS is to be able to publish a diagnostic message whenever an issue is detected in the user code. Diagnostics are often rendered by the IDE with a squiggle of different colour, depending on the severity of the message (e.g. a warning uses a yellow squiggle, while an error uses a red squiggle).
One of these messages is displayed whenever an
include
orinclude_lib
attribute is added to a module, but unused. See the picture below.A Code Action request is sent from the IDE to the language server to compute the possible code actions available for a given document and text range. In the case above, the following request is sent from the IDE to the language server as soon as the user hovers the unused include:
As you can see, the request contains the current location (file path, line number, line column) and an additional context (in this case a list containing one diagnostic, which can in turn be used by the server to provide a list of available code actions. Right now, since this feature is not yet implemented, no code actions (i.e. an empty list or
[]
) is returned to the client.What is Required
In case a
textDocument/codeAction
request is received by the language server, the server should check for presence of "Unused include" diagnostics. If one is present, the server should include a code action (sayremove-unused-include
) in the response.Once the possible code action is received by the IDE, the user gets notified. This usually happens via a little bulb icon or similar, which suggests that a code action is available. In this case, the code action would be of type quickfix and suggest to remove the unused include.
Code Pointers
els_code_action_provider
module, so you probably want to start thereTesting
Don't forget to include a test for the new functionality! You can look at existing examples in the
els_code_action_SUITE
module and at this code lenses tutorial which includes a testing overview which also applies to code actions.Problems following the instructions?
Get in touch! We'll be glad to help you to get unblocked and to improve our docs.
The text was updated successfully, but these errors were encountered: