Skip to content

Commit

Permalink
avoid starting both incremental and old dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed May 22, 2024
1 parent 13d768e commit 59040c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions apps/language_server/lib/language_server/dialyzer/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ defmodule ElixirLS.LanguageServer.Dialyzer.Supervisor do
alias ElixirLS.LanguageServer.{Dialyzer, DialyzerIncremental}
use Supervisor

def start_link(parent \\ self(), root_path) do
Supervisor.start_link(__MODULE__, {parent, root_path})
def start_link(parent \\ self(), name \\ nil, root_path, dialyzer_module) do
Supervisor.start_link(__MODULE__, {parent, root_path, dialyzer_module},
name: name || __MODULE__
)
end

@impl Supervisor
def init({parent, root_path}) do
def init({parent, root_path, dialyzer_module}) do
Supervisor.init(
[
{Dialyzer, {parent, root_path}},
{DialyzerIncremental, {parent, root_path}}
{dialyzer_module, {parent, root_path}}
],
strategy: :one_for_one
)
Expand Down
7 changes: 5 additions & 2 deletions apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ defmodule ElixirLS.LanguageServer.Server do
|> set_mix_env(mix_env)
|> set_mix_target(mix_target)
|> set_project_dir(project_dir)
|> Map.put(:settings, settings)
|> set_dialyzer_enabled(enable_dialyzer)

add_watched_extensions(state.server_instance_id, additional_watched_extensions)
Expand Down Expand Up @@ -1885,7 +1886,7 @@ defmodule ElixirLS.LanguageServer.Server do
%{}
)

trigger_build(%{state | settings: settings})
trigger_build(state)
end

defp add_watched_extensions(_server_instance_id, []) do
Expand Down Expand Up @@ -1963,7 +1964,9 @@ defmodule ElixirLS.LanguageServer.Server do
defp set_dialyzer_enabled(state = %__MODULE__{}, enable_dialyzer) do
cond do
enable_dialyzer and state.mix_project? and state.dialyzer_sup == nil ->
{:ok, pid} = Dialyzer.Supervisor.start_link(state.project_dir)
{:ok, pid} =
Dialyzer.Supervisor.start_link(state.project_dir, dialyzer_module(state.settings))

%{state | dialyzer_sup: pid, analysis_ready?: false}

not (enable_dialyzer and state.mix_project?) and state.dialyzer_sup != nil ->
Expand Down

0 comments on commit 59040c4

Please sign in to comment.