Skip to content

Commit c2338b7

Browse files
committed
fallback to mixfile path if diagnostic path is nil
1 parent 8f3df75 commit c2338b7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

apps/language_server/lib/language_server/build.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ defmodule ElixirLS.LanguageServer.Build do
6363
if Keyword.get(opts, :compile?) do
6464
{status, compile_diagnostics} = run_mix_compile()
6565

66-
compile_diagnostics = Diagnostics.normalize(compile_diagnostics, root_path)
66+
compile_diagnostics =
67+
Diagnostics.normalize(compile_diagnostics, root_path, mixfile)
6768

6869
Server.build_finished(
6970
parent,

apps/language_server/lib/language_server/diagnostics.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
defmodule ElixirLS.LanguageServer.Diagnostics do
22
alias ElixirLS.LanguageServer.{SourceFile, JsonRpc}
33

4-
def normalize(diagnostics, root_path) do
4+
def normalize(diagnostics, root_path, mixfile) do
55
for diagnostic <- diagnostics do
66
{type, file, position, description, stacktrace} =
77
extract_message_info(diagnostic.message, root_path)
88

99
diagnostic
1010
|> update_message(type, description, stacktrace)
11-
|> maybe_update_file(file)
11+
|> maybe_update_file(file, mixfile)
1212
|> maybe_update_position(type, position, stacktrace)
1313
end
1414
end
@@ -54,11 +54,15 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
5454
Map.put(diagnostic, :message, message)
5555
end
5656

57-
defp maybe_update_file(diagnostic, path) do
57+
defp maybe_update_file(diagnostic, path, mixfile) do
5858
if path do
5959
Map.put(diagnostic, :file, path)
6060
else
61-
diagnostic
61+
if is_nil(diagnostic.file) do
62+
Map.put(diagnostic, :file, mixfile)
63+
else
64+
diagnostic
65+
end
6266
end
6367
end
6468

0 commit comments

Comments
 (0)