Skip to content

Commit

Permalink
address todos
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Sep 10, 2022
1 parent 65e3a5b commit 37e2e0a
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions apps/language_server/lib/language_server/tracer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 37e2e0a

Please sign in to comment.