Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find references for atoms #1404

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/els_lsp/src/els_dt_references.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
| record
| include
| include_lib
| behaviour.
| behaviour
| atom.
-export_type([poi_category/0]).

%%==============================================================================
Expand Down Expand Up @@ -185,4 +186,6 @@ kind_to_category(Kind) when Kind =:= include ->
kind_to_category(Kind) when Kind =:= include_lib ->
include_lib;
kind_to_category(Kind) when Kind =:= behaviour ->
behaviour.
behaviour;
kind_to_category(Kind) when Kind =:= atom ->
atom.
4 changes: 3 additions & 1 deletion apps/els_lsp/src/els_indexing.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ index_references(Id, Uri, POIs, Version) ->
%% Behaviour
behaviour,
%% Type
type_application
type_application,
%% Atom
atom
],
[
index_reference(Id, Uri, POI, Version)
Expand Down
3 changes: 2 additions & 1 deletion apps/els_lsp/src/els_references_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ find_references(Uri, #{kind := module}) ->
Refs = find_references_to_module(Uri),
[location(U, R) || #{uri := U, range := R} <- Refs];
find_references(_Uri, #{kind := Kind, id := Name}) when
Kind =:= behaviour
Kind =:= behaviour;
Kind =:= atom
->
find_references_for_id(Kind, Name);
find_references(_Uri, _POI) ->
Expand Down
2 changes: 2 additions & 0 deletions apps/els_lsp/src/els_text_search.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extract_pattern({include, Id}) ->
extract_pattern({include_lib, Id}) ->
include_id(Id);
extract_pattern({behaviour, Name}) ->
Name;
extract_pattern({atom, Name}) ->
Name.

-spec include_id(string()) -> string().
Expand Down
27 changes: 27 additions & 0 deletions apps/els_lsp/test/els_references_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
type_local/1,
type_remote/1,
type_included/1,
atom/1,
refresh_after_watched_file_deleted/1,
refresh_after_watched_file_changed/1,
refresh_after_watched_file_added/1,
Expand Down Expand Up @@ -555,6 +556,32 @@ type_included(Config) ->
assert_locations(Locations, ExpectedLocations),
ok.

-spec atom(config()) -> ok.
atom(Config) ->
Uri = ?config(code_navigation_uri, Config),
%% References for the `code_navigation_extra' atom
#{result := Locations} = els_client:references(Uri, 85, 5),
ExpectedLocations = [
#{
uri => Uri,
range => #{from => {85, 3}, to => {85, 24}}
},
#{
uri => Uri,
range => #{from => {86, 14}, to => {86, 35}}
},
#{
uri => Uri,
range => #{from => {132, 36}, to => {132, 57}}
},
#{
uri => Uri,
range => #{from => {134, 35}, to => {134, 56}}
}
],
assert_locations(Locations, ExpectedLocations),
ok.

-spec refresh_after_watched_file_deleted(config()) -> ok.
refresh_after_watched_file_deleted(Config) ->
%% Before
Expand Down