Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: use MIX_BUILD_ROOT #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"{config,lib,}/**/*.{ex,exs}",
"test/credo_language_server_test.exs",
"test/test_helper.exs",
"test/credo_language_server/**/*.{ex,exs}"
"test/credo_language_server/**/*.{ex,exs}",
"priv/**/*.ex"
]
]
2 changes: 1 addition & 1 deletion lib/credo_language_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ defmodule CredoLanguageServer do
issues =
CredoLanguageServer.Runtime.call(
lsp.assigns.runtime,
{:_credo_language_server_private, :issues, [dir]}
{:_credo_language_server_private_credo, :issues, [dir]}
)

for issue <- issues do
Expand Down
32 changes: 25 additions & 7 deletions lib/credo_language_server/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ defmodule CredoLanguageServer.Runtime do
|> Path.join("cmd")
|> Path.absname()

unless macro_exported?(Kernel, :then, 2) do
defmacrop then(value, fun) do
quote do
unquote(fun).(unquote(value))
end
end
end

def start_link(opts) do
GenServer.start_link(__MODULE__, opts, Keyword.take(opts, [:name]))
end
Expand Down Expand Up @@ -48,7 +56,8 @@ defmodule CredoLanguageServer.Runtime do
:stream,
cd: working_dir,
env: [
{'MIX_ENV', 'credolsp'}
{'MIX_ENV', 'dev'},
{'MIX_BUILD_ROOT', '.elixir-tools/_build'}
],
args: [
System.find_executable("elixir"),
Expand All @@ -72,14 +81,23 @@ defmodule CredoLanguageServer.Runtime do
true <- connect(node, port, 120) do
send(parent, {:log, "Connected to node #{node}"})

file =
Path.join(
:code.priv_dir(:credo_language_server),
"monkey/_credo_language_server_private.ex"
:credo_language_server
|> :code.priv_dir()
|> Path.join("monkey/_credo_language_server_private_compiler.ex")
|> then(&:rpc.call(node, Code, :compile_file, [&1]))

:ok =
:rpc.call(
node,
:_credo_language_server_private_compiler,
:compile,
[]
)

:rpc.call(node, Code, :compile_file, [file])
:ok = :rpc.call(node, :_credo_language_server_private, :compile, [])
:credo_language_server
|> :code.priv_dir()
|> Path.join("monkey/_credo_language_server_private_credo.ex")
|> then(&:rpc.call(node, Code, :compile_file, [&1]))

send(me, {:node, node})
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
defmodule :_credo_language_server_private do
defmodule :_credo_language_server_private_compiler do
@moduledoc false

def issues(dir) do
["--strict", "--all", "--working-dir", dir]
|> Credo.run()
|> Credo.Execution.get_issues()
end

def compile() do
# keep stdout on this node
Process.group_leader(self(), Process.whereis(:user))
Expand All @@ -16,6 +10,6 @@ defmodule :_credo_language_server_private do

:ok
rescue
_ -> :error
e -> {:error, e}
end
end
9 changes: 9 additions & 0 deletions priv/monkey/_credo_language_server_private_credo.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule :_credo_language_server_private_credo do
@moduledoc false

def issues(dir) do
["--strict", "--all", "--working-dir", dir]
|> Credo.run()
|> Credo.Execution.get_issues()
end
end
4 changes: 2 additions & 2 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ timeout =
if System.get_env("CI", "false") == "true" do
60_000
else
10_000
30_000
end

ExUnit.start(assert_receive_timeout: timeout)
ExUnit.start(assert_receive_timeout: timeout, timeout: 120_000)