diff --git a/lib/elixir_sense/core/metadata_builder.ex b/lib/elixir_sense/core/metadata_builder.ex index 672b6e42..c9326586 100644 --- a/lib/elixir_sense/core/metadata_builder.ex +++ b/lib/elixir_sense/core/metadata_builder.ex @@ -1291,28 +1291,15 @@ defmodule ElixirSense.Core.MetadataBuilder do {ast, state} end - defp post({:defmodule, _, [{:__aliases__, _, _}, _]} = ast, state) do + defp post({:defmodule, _, [_module | _]} = ast, state) do post_module(ast, state) end - defp post({:defmodule, _, [module, _]} = ast, state) when is_atom(module) do - post_module(ast, state) - end - - defp post({:defprotocol, _, [{:__aliases__, _, _}, _]} = ast, state) do - post_protocol(ast, state) - end - - defp post({:defprotocol, _, [module, _]} = ast, state) when is_atom(module) do + defp post({:defprotocol, _, [_protocol | _]} = ast, state) do post_protocol(ast, state) end - defp post({:defimpl, _, [{:__aliases__, _, _}, [for: _implementations], _]} = ast, state) do - post_module(ast, state) - end - - defp post({:defimpl, _, [protocol, [for: _implementations], _]} = ast, state) - when is_atom(protocol) do + defp post({:defimpl, _, [_protocol | _]} = ast, state) do post_module(ast, state) end diff --git a/test/elixir_sense/core/metadata_builder/alias_test.exs b/test/elixir_sense/core/metadata_builder/alias_test.exs index e56ecc63..9bb9b411 100644 --- a/test/elixir_sense/core/metadata_builder/alias_test.exs +++ b/test/elixir_sense/core/metadata_builder/alias_test.exs @@ -33,7 +33,8 @@ defmodule ElixirSense.Core.MetadataBuilder.AliasTest do Alias.Realias, Alias.Unalias, Alias.NoUnaliasNested, - Alias.RequireWithAs + Alias.RequireWithAs, + Alias.AfterStructWithImplementation ] do test "alias rules properly handled in #{inspect(module)}" do state = diff --git a/test/support/fixtures/metadata_builder/alias/after_strct_with_implementation.ex b/test/support/fixtures/metadata_builder/alias/after_strct_with_implementation.ex new file mode 100644 index 00000000..8e296f58 --- /dev/null +++ b/test/support/fixtures/metadata_builder/alias/after_strct_with_implementation.ex @@ -0,0 +1,17 @@ +defprotocol ElixirSenseExample.ExampleProtocol1 do + @spec some(t) :: any + def some(t) +end + +defmodule ElixirSenseExample.Fixtures.MetadataBuilder.Alias.StructWithImplementation do + defstruct name_version: "", github_relative_path: "" + + defimpl ElixirSenseExample.ExampleProtocol1 do + def some(t), do: t + end +end + +defmodule ElixirSenseExample.Fixtures.MetadataBuilder.Alias.AfterStructWithImplementation do + @env __ENV__ + def env, do: @env +end