From 93505933a2908d02dad8cf7fbe278f4657e41dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Sun, 1 Nov 2020 12:39:55 -0500 Subject: [PATCH] Handle errors in server request --- .../lib/language_server/server.ex | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/language_server/lib/language_server/server.ex b/apps/language_server/lib/language_server/server.ex index 26faac8e8..594bb1eda 100644 --- a/apps/language_server/lib/language_server/server.ex +++ b/apps/language_server/lib/language_server/server.ex @@ -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} @@ -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