Skip to content

Commit

Permalink
correctly handle end of protocol implementation without for
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Jul 14, 2023
1 parent 83329e2 commit f7c36f8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
19 changes: 3 additions & 16 deletions lib/elixir_sense/core/metadata_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/elixir_sense/core/metadata_builder/alias_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7c36f8

Please sign in to comment.