Skip to content

Commit 98a676b

Browse files
committed
remove references to module variants
1 parent 8486de4 commit 98a676b

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

apps/debug_adapter/lib/debug_adapter/server.ex

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,17 +2059,26 @@ defmodule ElixirLS.DebugAdapter.Server do
20592059

20602060
for line <- lines do
20612061
env = ElixirSense.Core.Metadata.get_env(metadata, {line |> elem(0), 1})
2062-
metadata_modules = Enum.filter(env.module_variants, &(&1 != Elixir))
2062+
metadata_module = env.module
20632063

20642064
modules_to_break =
2065-
if metadata_modules != [] and
2066-
Enum.all?(metadata_modules, &(&1 in loaded_modules_from_path)) do
2067-
# prefer metadata modules if valid and loaded
2068-
metadata_modules
2069-
else
2070-
# fall back to all loaded modules from file
2071-
# this may create breakpoints outside module line range
2072-
loaded_modules_from_path
2065+
cond do
2066+
metadata_module != nil and metadata_module in loaded_modules_from_path and
2067+
env.protocol == nil ->
2068+
# prefer metadata modules if valid and loaded
2069+
[metadata_module]
2070+
2071+
env.protocol != nil ->
2072+
{protocol, implementations} = env.protocol
2073+
2074+
for implementation <- implementations do
2075+
Module.concat(protocol, implementation)
2076+
end
2077+
2078+
true ->
2079+
# fall back to all loaded modules from file
2080+
# this may create breakpoints outside module line range
2081+
loaded_modules_from_path
20732082
end
20742083

20752084
set_breakpoint(modules_to_break, path, line)

apps/language_server/lib/language_server/providers/implementation/locator.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ defmodule ElixirLS.LanguageServer.Providers.Implementation.Locator do
159159
metadata_implementations =
160160
for {_, env} <- metadata.lines_to_env,
161161
behaviour in env.behaviours,
162-
module <- env.module_variants,
163162
uniq: true,
164-
do: module
163+
do: env.module
165164

166165
metadata_implementations_locations =
167166
metadata_implementations

apps/language_server/lib/language_server/providers/references/locator.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ defmodule ElixirLS.LanguageServer.Providers.References.Locator do
3434

3535
env =
3636
%State.Env{
37-
module_variants: module_variants
37+
module: module
3838
} =
3939
Metadata.get_env(metadata, {line, column})
4040
|> Metadata.add_scope_vars(metadata, {line, column})
4141

4242
# find last env of current module
43-
attributes = get_attributes(metadata, module_variants)
43+
attributes = get_attributes(metadata, module)
4444

4545
# one line can contain variables from many scopes
4646
# if the cursor is over variable take variables from the scope as it will
@@ -72,9 +72,9 @@ defmodule ElixirLS.LanguageServer.Providers.References.Locator do
7272
end
7373
end
7474

75-
defp get_attributes(_metadata, []), do: []
75+
defp get_attributes(_metadata, nil), do: []
7676

77-
defp get_attributes(metadata, [module | _]) do
77+
defp get_attributes(metadata, module) do
7878
%State.Env{attributes: attributes} = Metadata.get_last_module_env(metadata, module)
7979

8080
attributes

0 commit comments

Comments
 (0)