Skip to content

Commit

Permalink
Goto type definition from export_type entry
Browse files Browse the repository at this point in the history
  • Loading branch information
plux committed Apr 8, 2021
1 parent 76fa5ff commit 1debea8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/els_lsp/priv/code_navigation/src/code_navigation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

%% behaviour_a callbacks
-export([ callback_a/0 ]).

-export_type([ type_a/0 ]).
-import(code_navigation_extra, [ do/1 ]).
-include("transitive.hrl").
-include("code_navigation.hrl").
Expand Down
3 changes: 2 additions & 1 deletion apps/els_lsp/src/els_code_navigation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ goto_definition(_Uri, #{ kind := type_application, id := {M, T, A} }) ->
{ok, Uri} -> find(Uri, type_definition, {T, A});
{error, Error} -> {error, Error}
end;
goto_definition(Uri, #{ kind := type_application, id := {T, A} }) ->
goto_definition(Uri, #{ kind := Kind, id := {T, A} })
when Kind =:= type_application; Kind =:= export_type_entry ->
find(Uri, type_definition, {T, A});
goto_definition(_Uri, #{ kind := parse_transform, id := Module }) ->
case els_utils:find_module(Module) of
Expand Down
11 changes: 11 additions & 0 deletions apps/els_lsp/test/els_definition_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
, type_application_remote/1
, type_application_undefined/1
, type_application_user/1
, type_export_entry/1
, variable/1
, opaque_application_remote/1
, opaque_application_user/1
Expand Down Expand Up @@ -401,6 +402,16 @@ type_application_user(Config) ->
, Range),
ok.

-spec type_export_entry(config()) -> ok.
type_export_entry(Config) ->
Uri = ?config(code_navigation_uri, Config),
Def = els_client:definition(Uri, 9, 17),
#{result := #{range := Range, uri := DefUri}} = Def,
?assertEqual(Uri, DefUri),
?assertEqual( els_protocol:range(#{from => {37, 7}, to => {37, 13}})
, Range),
ok.

-spec variable(config()) -> ok.
variable(Config) ->
Uri = ?config(code_navigation_uri, Config),
Expand Down

0 comments on commit 1debea8

Please sign in to comment.