Skip to content

Commit 4f91949

Browse files
committed
format
1 parent 24c7413 commit 4f91949

File tree

14 files changed

+270
-147
lines changed

14 files changed

+270
-147
lines changed

apps/elixir_ls_debugger/lib/debugger/breakpoint_condition.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ defmodule ElixirLS.Debugger.BreakpointCondition do
7878

7979
_other ->
8080
message = Exception.format_exit(reason)
81+
8182
Output.telemetry(
8283
"dap_server_error",
8384
%{

apps/elixir_ls_debugger/lib/debugger/server.ex

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ defmodule ElixirLS.Debugger.Server do
197197

198198
_other ->
199199
message = Exception.format_exit(reason)
200+
200201
Output.telemetry(
201202
"dap_server_error",
202203
%{
@@ -1603,14 +1604,19 @@ defmodule ElixirLS.Debugger.Server do
16031604
defp launch(config, server) do
16041605
project_dir = config["projectDir"]
16051606

1606-
project_dir = if project_dir not in [nil, ""] do
1607-
Output.debugger_console("Starting debugger in directory: #{project_dir}\n")
1608-
project_dir
1609-
else
1610-
cwd = File.cwd!()
1611-
Output.debugger_console("projectDir is not set, starting debugger in current directory: #{cwd}\n")
1612-
cwd
1613-
end
1607+
project_dir =
1608+
if project_dir not in [nil, ""] do
1609+
Output.debugger_console("Starting debugger in directory: #{project_dir}\n")
1610+
project_dir
1611+
else
1612+
cwd = File.cwd!()
1613+
1614+
Output.debugger_console(
1615+
"projectDir is not set, starting debugger in current directory: #{cwd}\n"
1616+
)
1617+
1618+
cwd
1619+
end
16141620

16151621
task = config["task"]
16161622
task_args = config["taskArgs"] || []

apps/language_server/lib/language_server/build.ex

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,79 @@ defmodule ElixirLS.LanguageServer.Build do
44
require Logger
55

66
def build(parent, root_path, opts) when is_binary(root_path) do
7-
spawn_monitor(fn ->
8-
with_build_lock(fn ->
9-
{us, result} =
10-
:timer.tc(fn ->
11-
Logger.info("Starting build with MIX_ENV: #{Mix.env()} MIX_TARGET: #{Mix.target()}")
12-
13-
# read cache before cleaning up mix state in reload_project
14-
cached_deps = read_cached_deps()
15-
16-
case reload_project() do
17-
{:ok, mixfile_diagnostics} ->
18-
ElixirLS.LanguageServer.MixProject.store()
19-
# FIXME: Private API
20-
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-
if Keyword.get(opts, :compile?) do
32-
{status, diagnostics} = run_mix_compile()
33-
34-
diagnostics = Diagnostics.normalize(diagnostics, root_path)
35-
Server.build_finished(parent, {status, mixfile_diagnostics ++ diagnostics})
36-
:"mix_compile_#{status}"
37-
else
38-
Server.build_finished(parent, {:ok, mixfile_diagnostics})
39-
:mix_compile_disabled
40-
end
41-
catch
42-
kind, payload ->
43-
{payload, stacktrace} = Exception.blame(kind, payload, __STACKTRACE__)
44-
message = Exception.format(kind, payload, stacktrace)
45-
Logger.warning("Mix.Dep.load_on_environment([]) failed: #{message}")
46-
47-
JsonRpc.telemetry(
48-
"build_error",
49-
%{"elixir_ls.build_error" => message},
50-
%{}
51-
)
52-
53-
# TODO pass diagnostic
54-
Server.build_finished(parent, {:error, []})
55-
:deps_error
7+
spawn_monitor(fn ->
8+
with_build_lock(fn ->
9+
{us, result} =
10+
:timer.tc(fn ->
11+
Logger.info("Starting build with MIX_ENV: #{Mix.env()} MIX_TARGET: #{Mix.target()}")
12+
13+
# read cache before cleaning up mix state in reload_project
14+
cached_deps = read_cached_deps()
15+
16+
case reload_project() do
17+
{:ok, mixfile_diagnostics} ->
18+
ElixirLS.LanguageServer.MixProject.store()
19+
# FIXME: Private API
20+
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)
5629
end
5730

58-
{:error, mixfile_diagnostics} ->
59-
Server.build_finished(parent, {:error, mixfile_diagnostics})
60-
:mixfile_error
31+
if Keyword.get(opts, :compile?) do
32+
{status, diagnostics} = run_mix_compile()
6133

62-
:no_mixfile ->
63-
Server.build_finished(parent, {:no_mixfile, []})
64-
:no_mixfile
65-
end
66-
end)
34+
diagnostics = Diagnostics.normalize(diagnostics, root_path)
35+
Server.build_finished(parent, {status, mixfile_diagnostics ++ diagnostics})
36+
:"mix_compile_#{status}"
37+
else
38+
Server.build_finished(parent, {:ok, mixfile_diagnostics})
39+
:mix_compile_disabled
40+
end
41+
catch
42+
kind, payload ->
43+
{payload, stacktrace} = Exception.blame(kind, payload, __STACKTRACE__)
44+
message = Exception.format(kind, payload, stacktrace)
45+
Logger.warning("Mix.Dep.load_on_environment([]) failed: #{message}")
46+
47+
JsonRpc.telemetry(
48+
"build_error",
49+
%{"elixir_ls.build_error" => message},
50+
%{}
51+
)
6752

68-
if Keyword.get(opts, :compile?) do
69-
Tracer.save()
70-
Logger.info("Compile took #{div(us, 1000)} milliseconds")
71-
else
72-
Logger.info("Mix project load took #{div(us, 1000)} milliseconds")
73-
end
53+
# TODO pass diagnostic
54+
Server.build_finished(parent, {:error, []})
55+
:deps_error
56+
end
57+
58+
{:error, mixfile_diagnostics} ->
59+
Server.build_finished(parent, {:error, mixfile_diagnostics})
60+
:mixfile_error
61+
62+
:no_mixfile ->
63+
Server.build_finished(parent, {:no_mixfile, []})
64+
:no_mixfile
65+
end
66+
end)
67+
68+
if Keyword.get(opts, :compile?) do
69+
Tracer.save()
70+
Logger.info("Compile took #{div(us, 1000)} milliseconds")
71+
else
72+
Logger.info("Mix project load took #{div(us, 1000)} milliseconds")
73+
end
7474

75-
JsonRpc.telemetry("build", %{"elixir_ls.build_result" => result}, %{
76-
"elixir_ls.build_time" => div(us, 1000)
77-
})
78-
end)
75+
JsonRpc.telemetry("build", %{"elixir_ls.build_result" => result}, %{
76+
"elixir_ls.build_time" => div(us, 1000)
77+
})
7978
end)
79+
end)
8080
end
8181

8282
def clean(clean_deps? \\ false) do

apps/language_server/lib/language_server/dialyzer.ex

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
113113
_from,
114114
state
115115
) do
116-
diagnostics = to_diagnostics(warnings, state.warn_opts, state.warning_format, state.project_dir, state.deps_path)
116+
diagnostics =
117+
to_diagnostics(
118+
warnings,
119+
state.warn_opts,
120+
state.warning_format,
121+
state.project_dir,
122+
state.deps_path
123+
)
117124

118125
Server.dialyzer_finished(state.parent, diagnostics, build_ref)
119126

@@ -160,7 +167,14 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
160167
new_timestamp = adjusted_timestamp()
161168

162169
{removed_files, file_changes} =
163-
update_stale(state.md5, state.removed_files, state.file_changes, state.timestamp, project_dir, build_path)
170+
update_stale(
171+
state.md5,
172+
state.removed_files,
173+
state.file_changes,
174+
state.timestamp,
175+
project_dir,
176+
build_path
177+
)
164178

165179
state = %{
166180
state
@@ -202,6 +216,7 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
202216

203217
_other ->
204218
message = Exception.format_exit(reason)
219+
205220
JsonRpc.telemetry(
206221
"lsp_server_error",
207222
%{
@@ -214,10 +229,10 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
214229
Logger.info("Terminating #{__MODULE__}: #{message}")
215230

216231
JsonRpc.show_message(
217-
:error,
218-
"ElixirLS Dialyzer had an error. If this happens repeatedly, set " <>
219-
"\"elixirLS.dialyzerEnabled\" to false in settings.json to disable it"
220-
)
232+
:error,
233+
"ElixirLS Dialyzer had an error. If this happens repeatedly, set " <>
234+
"\"elixirLS.dialyzerEnabled\" to false in settings.json to disable it"
235+
)
221236
end
222237
end
223238

@@ -349,7 +364,11 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
349364
end
350365

351366
defp temp_file_path(root_path, file) do
352-
Path.join([root_path, ".elixir_ls/dialyzer_#{System.otp_release()}_#{System.version()}_tmp", file])
367+
Path.join([
368+
root_path,
369+
".elixir_ls/dialyzer_#{System.otp_release()}_#{System.version()}_tmp",
370+
file
371+
])
353372
end
354373

355374
defp write_temp_file(root_path, file_path, content) do

apps/language_server/lib/language_server/ex_unit_test_tracer.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ defmodule ElixirLS.LanguageServer.ExUnitTestTracer do
5252

5353
_other ->
5454
message = Exception.format_exit(reason)
55+
5556
JsonRpc.telemetry(
5657
"lsp_server_error",
5758
%{

apps/language_server/lib/language_server/mix_project.ex

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ defmodule ElixirLS.LanguageServer.MixProject do
103103
@spec app_path() :: Path.t()
104104
def app_path() do
105105
config = config()
106+
106107
config[:deps_app_path] ||
107108
cond do
108109
app = config[:app] ->
@@ -149,6 +150,7 @@ defmodule ElixirLS.LanguageServer.MixProject do
149150

150151
_other ->
151152
message = Exception.format_exit(reason)
153+
152154
JsonRpc.telemetry(
153155
"lsp_server_error",
154156
%{
@@ -171,20 +173,20 @@ defmodule ElixirLS.LanguageServer.MixProject do
171173

172174
def handle_call(:store, _from, _state) do
173175
state = %{
174-
get: Mix.Project.get(),
175-
project_file: Mix.Project.project_file(),
176-
config: Mix.Project.config(),
177-
config_files: Mix.Project.config_files(),
178-
config_mtime: Mix.Project.config_mtime(),
179-
umbrella?: Mix.Project.umbrella?(),
180-
apps_paths: Mix.Project.apps_paths(),
181-
deps_path: Mix.Project.deps_path(),
182-
deps_apps: Mix.Project.deps_apps(),
183-
deps_scms: Mix.Project.deps_scms(),
184-
deps_paths: Mix.Project.deps_paths(),
185-
build_path: Mix.Project.build_path(),
186-
manifest_path: Mix.Project.manifest_path(),
187-
consolidation_path: Mix.Project.consolidation_path()
176+
get: Mix.Project.get(),
177+
project_file: Mix.Project.project_file(),
178+
config: Mix.Project.config(),
179+
config_files: Mix.Project.config_files(),
180+
config_mtime: Mix.Project.config_mtime(),
181+
umbrella?: Mix.Project.umbrella?(),
182+
apps_paths: Mix.Project.apps_paths(),
183+
deps_path: Mix.Project.deps_path(),
184+
deps_apps: Mix.Project.deps_apps(),
185+
deps_scms: Mix.Project.deps_scms(),
186+
deps_paths: Mix.Project.deps_paths(),
187+
build_path: Mix.Project.build_path(),
188+
manifest_path: Mix.Project.manifest_path(),
189+
consolidation_path: Mix.Project.consolidation_path()
188190
}
189191

190192
{:reply, :ok, state}

0 commit comments

Comments
 (0)