File tree Expand file tree Collapse file tree
elixir_sense/providers/definition Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,4 +53,46 @@ defmodule ElixirSense.Providers.Definition.LocatorTest do
5353 assert location . line == 4
5454 assert location . column == 11
5555 end
56+
57+ test "finds definition of function defined in __using__ macro from external file" do
58+ code = """
59+ defmodule MyModule do
60+ use ElixirSenseExample.UsingMacroExample
61+
62+ def test do
63+ using_macro_function()
64+ end
65+ end
66+ """
67+
68+ { line , column } = { 5 , 5 }
69+
70+ location = Locator . definition ( code , line , column )
71+
72+ assert location != nil
73+ assert location . type == :function
74+ assert location . file =~ "using_macro_example.ex"
75+ assert location . line == 4
76+ assert location . column == 11
77+ end
78+
79+ test "finds definition of function defined in __using__ macro via module from external file" do
80+ code = """
81+ defmodule MyModule do
82+ def test do
83+ ElixirSenseExample.ModuleUsingMacroExample.using_macro_function()
84+ end
85+ end
86+ """
87+
88+ { line , column } = { 3 , 49 }
89+
90+ location = Locator . definition ( code , line , column )
91+
92+ assert location != nil
93+ assert location . type == :function
94+ assert location . file =~ "using_macro_example.ex"
95+ assert location . line == 4
96+ assert location . column == 11
97+ end
5698end
Original file line number Diff line number Diff line change 1+ defmodule ElixirSenseExample.UsingMacroExample do
2+ defmacro __using__ ( _opts ) do
3+ quote do
4+ def using_macro_function ( ) , do: :ok
5+ end
6+ end
7+ end
8+
9+ defmodule ElixirSenseExample.ModuleUsingMacroExample do
10+ use ElixirSenseExample.UsingMacroExample
11+ end
You can’t perform that action at this time.
0 commit comments