From 37e2e0aa9556395133b42480e3ad18c242559f04 Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Sat, 10 Sep 2022 19:17:18 +0200 Subject: [PATCH] address todos --- .../lib/language_server/tracer.ex | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/language_server/lib/language_server/tracer.ex b/apps/language_server/lib/language_server/tracer.ex index 0c9970a7b..00cd5baeb 100644 --- a/apps/language_server/lib/language_server/tracer.ex +++ b/apps/language_server/lib/language_server/tracer.ex @@ -120,8 +120,10 @@ defmodule ElixirLS.LanguageServer.Tracer do def close_table(table, project_dir) do path = dets_path(project_dir, table) - # TODO sync ets - case :dets.close(table_name(table)) do + table_name = table_name(table) + sync(table_name) + + case :dets.close(table_name) do :ok -> :ok @@ -162,11 +164,6 @@ defmodule ElixirLS.LanguageServer.Tracer do :ok end - # TODO sync on stop? - # def trace(:stop, %Macro.Env{} = env) do - # :ok - # end - def trace({:on_module, _, _}, %Macro.Env{} = env) do info = build_module_info(env.module, env.file, env.line) :ets.insert(table_name(:modules), {env.module, info}) @@ -273,13 +270,17 @@ defmodule ElixirLS.LanguageServer.Tracer do for table <- @tables do table_name = table_name(table) - with :ok <- :dets.from_ets(table_name, table_name), - :ok <- :dets.sync(table_name) do - :ok - else - {:error, reason} -> - Logger.error("Unable to sync DETS #{table_name}, #{inspect(reason)}") - end + sync(table_name) + end + end + + defp sync(table_name) do + with :ok <- :dets.from_ets(table_name, table_name), + :ok <- :dets.sync(table_name) do + :ok + else + {:error, reason} -> + Logger.error("Unable to sync DETS #{table_name}, #{inspect(reason)}") end end