Skip to content

Commit

Permalink
Handle errors in server request
Browse files Browse the repository at this point in the history
  • Loading branch information
Étienne Lévesque committed Nov 1, 2020
1 parent bd49269 commit 9350593
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,21 @@ defmodule ElixirLS.LanguageServer.Server do

defp handle_request(code_lens_req(_id, uri), state) do
fun = fn ->
{:ok, spec_code_lens} =
if dialyzer_enabled?(state) and state.settings["suggestSpecs"] != false do
CodeLens.spec_code_lens(state.server_instance_id, uri, state.source_files[uri].text)
else
[]
end
with {:ok, spec_code_lens} <- get_spec_code_lens(state, uri),
{:ok, test_code_lens} <- CodeLens.test_code_lens(uri, state.source_files[uri].text) do
{:ok, spec_code_lens ++ test_code_lens}
end

# {:ok, spec_code_lens} =
# if dialyzer_enabled?(state) and state.settings["suggestSpecs"] != false do
# CodeLens.spec_code_lens(state.server_instance_id, uri, state.source_files[uri].text)
# else
# {:ok, []}
# end

{:ok, test_code_lens} = CodeLens.test_code_lens(uri, state.source_files[uri].text)
# {:ok, test_code_lens} = CodeLens.test_code_lens(uri, state.source_files[uri].text)

{:ok, spec_code_lens ++ test_code_lens}
# {:ok, spec_code_lens ++ test_code_lens}
end

{:async, fun, state}
Expand Down Expand Up @@ -602,6 +607,14 @@ defmodule ElixirLS.LanguageServer.Server do
}
end

defp get_spec_code_lens(state, uri) do
if dialyzer_enabled?(state) and state.settings["suggestSpecs"] != false do
CodeLens.spec_code_lens(state.server_instance_id, uri, state.source_files[uri].text)
else
{:ok, []}
end
end

# Build

defp trigger_build(state) do
Expand Down

0 comments on commit 9350593

Please sign in to comment.