Skip to content

Commit 13b96ef

Browse files
authored
Directly warn user when mixfile is not found (#297)
* Directly warn user when mixfile is not found Without all three types of warnings it can be easy to miss this error, especially if the file that you have open is not mix.exs * Update changelog
1 parent 5102f1c commit 13b96ef

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Improvements:
77
- Support WorkspaceSymbols (go to symbol in workspace) without dialyzer being enabled (thanks [Jason Axelson](https://github.com/axelson)) [#263](https://github.com/elixir-lsp/elixir-ls/pull/263)
88
- Display the version of Elixir used to compile ELixirLS (thanks [Jason Axelson](https://github.com/axelson)) [#264](https://github.com/elixir-lsp/elixir-ls/pull/264)
99
- Support completion of callback function definitions (thanks [Marlus Saraiva](https://github.com/msaraiva)) [#265](https://github.com/elixir-lsp/elixir-ls/pull/265)
10+
- Give more direct warnings when mix.exs cannot be found (thanks [Jason Axelson](https://github.com/axelson)) [#297](https://github.com/elixir-lsp/elixir-ls/pull/297)
1011

1112
Changes:
1213
- Major improvement/change: Improve autocomplete and signature help (thanks [Marlus Saraiva](https://github.com/msaraiva)) [#273](https://github.com/elixir-lsp/elixir-ls/pull/273)

apps/language_server/lib/language_server/build.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ defmodule ElixirLS.LanguageServer.Build do
162162
"No mixfile found in project. " <>
163163
"To use a subdirectory, set `elixirLS.projectDir` in your settings"
164164

165+
JsonRpc.log_message(:error, msg <> ". Looked for mixfile at #{inspect(mixfile)}")
166+
JsonRpc.show_message(:error, msg)
167+
165168
{:error, [mixfile_diagnostic({Path.absname(mixfile), nil, msg}, :error)]}
166169
end
167170
end

apps/language_server/test/server_test.exs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ defmodule ElixirLS.LanguageServer.ServerTest do
317317
end)
318318
end
319319

320-
test "reports error if no mixfile", %{server: server} do
320+
test "reports errors if no mixfile", %{server: server} do
321321
in_fixture(__DIR__, "no_mixfile", fn ->
322322
mixfile_uri = SourceFile.path_to_uri("mix.exs")
323323

@@ -333,6 +333,14 @@ defmodule ElixirLS.LanguageServer.ServerTest do
333333
]
334334
}),
335335
5000
336+
337+
assert_receive notification("window/logMessage", %{
338+
"message" => "No mixfile found in project." <> _
339+
})
340+
341+
assert_receive notification("window/showMessage", %{
342+
"message" => "No mixfile found in project." <> _
343+
})
336344
end)
337345
end
338346

0 commit comments

Comments
 (0)