Skip to content

Commit 7c0ebda

Browse files
committed
format
1 parent e31d2c9 commit 7c0ebda

File tree

4 files changed

+84
-50
lines changed

4 files changed

+84
-50
lines changed

apps/language_server/lib/language_server/build.ex

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,43 @@ defmodule ElixirLS.LanguageServer.Build do
1616

1717
case reload_project(mixfile) do
1818
{:ok, mixfile_diagnostics} ->
19-
{deps_result, deps_raw_diagnostics} = with_diagnostics([log: true], fn ->
20-
try do
21-
# this call can raise
22-
current_deps = Mix.Dep.load_on_environment([])
23-
24-
purge_changed_deps(current_deps, cached_deps)
25-
26-
if Keyword.get(opts, :fetch_deps?) and current_deps != cached_deps do
27-
fetch_deps(current_deps)
19+
{deps_result, deps_raw_diagnostics} =
20+
with_diagnostics([log: true], fn ->
21+
try do
22+
# this call can raise
23+
current_deps = Mix.Dep.load_on_environment([])
24+
25+
purge_changed_deps(current_deps, cached_deps)
26+
27+
if Keyword.get(opts, :fetch_deps?) and current_deps != cached_deps do
28+
fetch_deps(current_deps)
29+
end
30+
31+
state = %{
32+
get: Mix.Project.get(),
33+
# project_file: Mix.Project.project_file(),
34+
config: Mix.Project.config(),
35+
# config_files: Mix.Project.config_files(),
36+
config_mtime: Mix.Project.config_mtime(),
37+
umbrella?: Mix.Project.umbrella?(),
38+
apps_paths: Mix.Project.apps_paths(),
39+
# deps_path: Mix.Project.deps_path(),
40+
# deps_apps: Mix.Project.deps_apps(),
41+
# deps_scms: Mix.Project.deps_scms(),
42+
deps_paths: Mix.Project.deps_paths(),
43+
# build_path: Mix.Project.build_path(),
44+
manifest_path: Mix.Project.manifest_path()
45+
}
46+
47+
ElixirLS.LanguageServer.MixProject.store(state)
48+
49+
:ok
50+
catch
51+
kind, err ->
52+
{payload, stacktrace} = Exception.blame(kind, err, __STACKTRACE__)
53+
{:error, kind, payload, stacktrace}
2854
end
29-
30-
state = %{
31-
get: Mix.Project.get(),
32-
# project_file: Mix.Project.project_file(),
33-
config: Mix.Project.config(),
34-
# config_files: Mix.Project.config_files(),
35-
config_mtime: Mix.Project.config_mtime(),
36-
umbrella?: Mix.Project.umbrella?(),
37-
apps_paths: Mix.Project.apps_paths(),
38-
# deps_path: Mix.Project.deps_path(),
39-
# deps_apps: Mix.Project.deps_apps(),
40-
# deps_scms: Mix.Project.deps_scms(),
41-
deps_paths: Mix.Project.deps_paths(),
42-
# build_path: Mix.Project.build_path(),
43-
manifest_path: Mix.Project.manifest_path()
44-
}
45-
ElixirLS.LanguageServer.MixProject.store(state)
46-
47-
:ok
48-
catch
49-
kind, err ->
50-
{payload, stacktrace} = Exception.blame(kind, err, __STACKTRACE__)
51-
{:error, kind, payload, stacktrace}
52-
end
53-
end)
55+
end)
5456

5557
deps_diagnostics =
5658
deps_raw_diagnostics
@@ -62,15 +64,32 @@ defmodule ElixirLS.LanguageServer.Build do
6264
{status, compile_diagnostics} = run_mix_compile()
6365

6466
compile_diagnostics = Diagnostics.normalize(compile_diagnostics, root_path)
65-
Server.build_finished(parent, {status, mixfile_diagnostics ++ deps_diagnostics ++ compile_diagnostics})
67+
68+
Server.build_finished(
69+
parent,
70+
{status, mixfile_diagnostics ++ deps_diagnostics ++ compile_diagnostics}
71+
)
72+
6673
:"mix_compile_#{status}"
6774
else
68-
Server.build_finished(parent, {:ok, mixfile_diagnostics ++ deps_diagnostics})
75+
Server.build_finished(
76+
parent,
77+
{:ok, mixfile_diagnostics ++ deps_diagnostics}
78+
)
79+
6980
:mix_compile_disabled
7081
end
82+
7183
{:error, kind, err, stacktrace} ->
7284
# TODO get path from exception message
73-
Server.build_finished(parent, {:error, mixfile_diagnostics ++ deps_diagnostics ++ [Diagnostics.error_to_diagnostic(kind, err, stacktrace, mixfile)]})
85+
Server.build_finished(
86+
parent,
87+
{:error,
88+
mixfile_diagnostics ++
89+
deps_diagnostics ++
90+
[Diagnostics.error_to_diagnostic(kind, err, stacktrace, mixfile)]}
91+
)
92+
7493
:deps_error
7594
end
7695

apps/language_server/lib/language_server/dialyzer.ex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,24 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
319319
{:ok, _} ->
320320
Logger.info("Beam file #{inspect(beam_path)} removed")
321321
:ok
322+
322323
rm_error ->
323-
Logger.warning("Unable to remove beam file #{inspect(beam_path)}: #{inspect(rm_error)}")
324+
Logger.warning(
325+
"Unable to remove beam file #{inspect(beam_path)}: #{inspect(rm_error)}"
326+
)
327+
324328
JsonRpc.show_message(
325329
:error,
326-
"ElixirLS Dialyzer is unable to process #{inspect(beam_path)}. Please remove it manually")
330+
"ElixirLS Dialyzer is unable to process #{inspect(beam_path)}. Please remove it manually"
331+
)
327332
end
333+
328334
_ ->
329335
JsonRpc.show_message(
330-
:error,
331-
"ElixirLS Dialyzer is unable to process one of the beam files. Please remove .elixir_ls/dialyzer* directory manually")
336+
:error,
337+
"ElixirLS Dialyzer is unable to process one of the beam files. Please remove .elixir_ls/dialyzer* directory manually"
338+
)
339+
332340
:ok
333341
end
334342

apps/language_server/lib/language_server/server.ex

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,7 @@ defmodule ElixirLS.LanguageServer.Server do
18631863
{:ok, cwd} ->
18641864
if Path.absname(cwd) == Path.absname(project_dir) do
18651865
mixfile = Path.absname(MixfileHelpers.mix_exs())
1866+
18661867
case Build.reload_project(mixfile) do
18671868
{:ok, _} ->
18681869
Build.clean(true)
@@ -1872,9 +1873,12 @@ defmodule ElixirLS.LanguageServer.Server do
18721873
:ok
18731874
end
18741875
else
1875-
message = "Unable to reload project: cwd #{inspect(cwd)} is not project dir #{project_dir}"
1876+
message =
1877+
"Unable to reload project: cwd #{inspect(cwd)} is not project dir #{project_dir}"
1878+
18761879
Logger.error(message)
1877-
JsonRpc.telemetry(
1880+
1881+
JsonRpc.telemetry(
18781882
"lsp_server_error",
18791883
%{
18801884
"elixir_ls.lsp_process" => inspect(__MODULE__),
@@ -1883,17 +1887,19 @@ defmodule ElixirLS.LanguageServer.Server do
18831887
%{}
18841888
)
18851889
end
1890+
18861891
{:error, reason} ->
18871892
message = "Unable to reload project: #{inspect(reason)}"
18881893
Logger.error(message)
1894+
18891895
JsonRpc.telemetry(
1890-
"lsp_server_error",
1891-
%{
1892-
"elixir_ls.lsp_process" => inspect(__MODULE__),
1893-
"elixir_ls.lsp_server_error" => message
1894-
},
1895-
%{}
1896-
)
1896+
"lsp_server_error",
1897+
%{
1898+
"elixir_ls.lsp_process" => inspect(__MODULE__),
1899+
"elixir_ls.lsp_server_error" => message
1900+
},
1901+
%{}
1902+
)
18971903
end
18981904
end
18991905
end

apps/language_server/test/providers/formatting_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
561561
# build_path: Mix.Project.build_path(),
562562
manifest_path: Mix.Project.manifest_path()
563563
}
564+
564565
MixProject.store(state)
565566
end
566567
end

0 commit comments

Comments
 (0)