Skip to content

Commit

Permalink
Revert "Add basic code action support (elixir-lsp#718)"
Browse files Browse the repository at this point in the history
This reverts commit 9fe8ea1.
  • Loading branch information
scohen committed Nov 23, 2022
1 parent 2984b66 commit 80714bb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 144 deletions.
11 changes: 0 additions & 11 deletions apps/language_server/lib/language_server/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,6 @@ defmodule ElixirLS.LanguageServer.Protocol do
end
end

defmacro code_action_req(id, uri, diagnostics) do
quote do
request(unquote(id), "textDocument/codeAction", %{
"context" => %{"diagnostics" => unquote(diagnostics)},
"textDocument" => %{
"uri" => unquote(uri)
}
})
end
end

# Other utilities

defmacro range(start_line, start_character, end_line, end_character) do
Expand Down
61 changes: 0 additions & 61 deletions apps/language_server/lib/language_server/providers/code_action.ex

This file was deleted.

10 changes: 2 additions & 8 deletions apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ defmodule ElixirLS.LanguageServer.Server do
OnTypeFormatting,
CodeLens,
ExecuteCommand,
FoldingRange,
CodeAction
FoldingRange
}

alias ElixirLS.Utils.Launch
Expand Down Expand Up @@ -780,10 +779,6 @@ defmodule ElixirLS.LanguageServer.Server do
end
end

defp handle_request(code_action_req(_id, uri, diagnostics), state = %__MODULE__{}) do
{:async, fn -> CodeAction.code_actions(uri, diagnostics) end, state}
end

defp handle_request(%{"method" => "$/" <> _}, state = %__MODULE__{}) do
# "$/" requests that the server doesn't support must return method_not_found
{:error, :method_not_found, nil, state}
Expand Down Expand Up @@ -835,8 +830,7 @@ defmodule ElixirLS.LanguageServer.Server do
"workspace" => %{
"workspaceFolders" => %{"supported" => false, "changeNotifications" => false}
},
"foldingRangeProvider" => true,
"codeActionProvider" => true
"foldingRangeProvider" => true
}
end

Expand Down
64 changes: 0 additions & 64 deletions apps/language_server/test/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,70 +1525,6 @@ defmodule ElixirLS.LanguageServer.ServerTest do
end
end

describe "textDocument/codeAction" do
test "return code actions on unused variables", %{server: server} do
uri = "file:///file.ex"
fake_initialize(server)

Server.receive_packet(server, did_open(uri, "elixir", 1, ""))

Server.receive_packet(
server,
code_action_req(1, uri, [
%{
"message" =>
"variable \"foo\" is unused (if the variable is not meant to be used, prefix it with an underscore)",
"range" => %{
"end" => %{"character" => 13, "line" => 19},
"start" => %{"character" => 4, "line" => 19}
},
"severity" => 1,
"source" => "Elixir"
}
])
)

resp = assert_receive(%{"id" => 1}, 5000)

assert response(1, [
%{
"edit" => %{
"changes" => %{
"file:///file.ex" => [
%{
"newText" => "_",
"range" => %{
"end" => %{"character" => 4, "line" => 19},
"start" => %{"character" => 4, "line" => 19}
}
}
]
}
},
"kind" => "quickfix",
"title" => "Add '_' to unused variable"
},
%{
"edit" => %{
"changes" => %{
"file:///file.ex" => [
%{
"newText" => "",
"range" => %{
"end" => %{"character" => 13, "line" => 19},
"start" => %{"character" => 4, "line" => 19}
}
}
]
}
},
"kind" => "quickfix",
"title" => "Remove unused variable"
}
]) == resp
end
end

defp with_new_server(func) do
server = start_supervised!({Server, nil})
packet_capture = start_supervised!({PacketCapture, self()})
Expand Down

0 comments on commit 80714bb

Please sign in to comment.