Skip to content

Commit

Permalink
return references if no definitions are found
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGeorge committed Apr 9, 2021
1 parent 36bf081 commit 028e7f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/els_lsp/src/els_definition_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

-include("els_lsp.hrl").


-type state() :: any().

%%==============================================================================
Expand All @@ -27,7 +28,12 @@ handle_request({definition, Params}, State) ->
} = Params,
{ok, Document} = els_utils:lookup_document(Uri),
POIs = els_dt_document:get_element_at_pos(Document, Line + 1, Character + 1),
{goto_definition(Uri, POIs), State}.
case goto_definition(Uri, POIs) of
null ->
els_references_provider:handle_request({references, Params}, State);
GoTo ->
{GoTo, State}
end.

-spec goto_definition(uri(), [poi()]) -> map() | null.
goto_definition(_Uri, []) ->
Expand Down
7 changes: 6 additions & 1 deletion apps/els_lsp/test/els_definition_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,12 @@ type_application_undefined(Config) ->
Uri = ?config(code_navigation_uri, Config),
Def = els_client:definition(Uri, 55, 42),
#{result := Result} = Def,
?assertEqual(null, Result),
Expected = [
#{ range => #{'end' => #{character => 49, line => 54},
start => #{character => 33, line => 54}}
, uri => Uri}
],
?assertEqual(Expected, Result),
ok.

-spec type_application_user(config()) -> ok.
Expand Down

0 comments on commit 028e7f1

Please sign in to comment.