From 59040c451fca11f5167e03432390f71602270ca6 Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Wed, 22 May 2024 10:14:47 +0200 Subject: [PATCH] avoid starting both incremental and old dialyzer --- .../lib/language_server/dialyzer/supervisor.ex | 11 ++++++----- apps/language_server/lib/language_server/server.ex | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/language_server/lib/language_server/dialyzer/supervisor.ex b/apps/language_server/lib/language_server/dialyzer/supervisor.ex index 7e3423731..9c44b8edb 100644 --- a/apps/language_server/lib/language_server/dialyzer/supervisor.ex +++ b/apps/language_server/lib/language_server/dialyzer/supervisor.ex @@ -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 ) diff --git a/apps/language_server/lib/language_server/server.ex b/apps/language_server/lib/language_server/server.ex index 21371d771..a90fae48c 100644 --- a/apps/language_server/lib/language_server/server.ex +++ b/apps/language_server/lib/language_server/server.ex @@ -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) @@ -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 @@ -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 ->