Skip to content

Commit f09c366

Browse files
committed
ok now?
1 parent 8e9de96 commit f09c366

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

apps/els_lsp/src/els_code_navigation.erl

+4-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
%% Includes
1818
%%==============================================================================
1919
-include("els_lsp.hrl").
20-
-include_lib("kernel/include/logger.hrl").
20+
2121
%%==============================================================================
2222
%% Type definitions
2323
%%==============================================================================
@@ -209,15 +209,11 @@ find_in_document([Uri | Uris0], Document, Kind, Data, AlreadyVisited) ->
209209
Kind =:= define;
210210
Kind =:= type_definition
211211
->
212-
?LOG_INFO("uri: ~p", [Uri]),
213-
?LOG_INFO("find in document any arity! ~p ~p", [Kind, Data]),
214212
%% Including defs with any arity
215213
AnyArity = [
216214
POI
217-
|| #{id := {F, _}} = POI <- POIs,
218-
Data =:= {F, any_arity}
215+
|| #{id := {F, _}} = POI <- POIs, Data =:= {F, any_arity}
219216
],
220-
?LOG_INFO("any arity: ~p", [AnyArity]),
221217
{AnyArity, true};
222218
_ ->
223219
{Defs, false}
@@ -240,7 +236,8 @@ find_in_document([Uri | Uris0], Document, Kind, Data, AlreadyVisited) ->
240236
case MultipleDefs of
241237
true ->
242238
%% This will be the case only when the user tries to
243-
%% navigate to the definition of an atom
239+
%% navigate to the definition of an atom or a
240+
%% function/type/macro of wrong arity.
244241
[{Uri, POI} || POI <- SortedDefs];
245242
false ->
246243
%% In the general case, we return only one def

apps/els_lsp/src/els_definition_provider.erl

+10-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
]).
88

99
-include("els_lsp.hrl").
10-
-include_lib("kernel/include/logger.hrl").
10+
1111
%%==============================================================================
1212
%% els_provider functions
1313
%%==============================================================================
@@ -24,19 +24,13 @@ handle_request({definition, Params}) ->
2424
POIs = els_dt_document:get_element_at_pos(Document, Line + 1, Character + 1),
2525
case goto_definition(Uri, POIs) of
2626
null ->
27-
?LOG_INFO("goto defintion failed", []),
28-
#{
29-
text := Text
30-
} = Document,
27+
#{text := Text} = Document,
3128
IncompletePOIs = match_incomplete(Text, {Line, Character}),
32-
?LOG_INFO("Incomplete pois: ~p", [IncompletePOIs]),
3329
case goto_definition(Uri, IncompletePOIs) of
3430
null ->
35-
Fuzzy = make_fuzzy(POIs),
36-
?LOG_INFO("FUZZY: ~p", [Fuzzy]),
37-
case goto_definition(Uri, Fuzzy) of
31+
FuzzyPOIs = make_fuzzy(POIs),
32+
case goto_definition(Uri, FuzzyPOIs) of
3833
null ->
39-
?LOG_INFO("goto defintion failed AGAIN", []),
4034
els_references_provider:handle_request({references, Params});
4135
GoTo ->
4236
{response, GoTo}
@@ -45,11 +39,10 @@ handle_request({definition, Params}) ->
4539
{response, GoTo}
4640
end;
4741
GoTo ->
48-
?LOG_INFO("goto??? ~p", [GoTo]),
4942
{response, GoTo}
5043
end.
5144

52-
-spec make_fuzzy(els_poi:poi()) -> els_poi:poi() | foo_bar_baz(1).
45+
-spec make_fuzzy([els_poi:poi()]) -> [els_poi:poi()].
5346
make_fuzzy(POIs) ->
5447
lists:flatmap(
5548
fun
@@ -82,6 +75,10 @@ make_fuzzy(POIs) ->
8275
POI#{id => M},
8376
POI#{id => {M, any_arity}}
8477
];
78+
(#{kind := macro, id := M} = POI) ->
79+
[
80+
POI#{id => {M, any_arity}}
81+
];
8582
(#{kind := atom, id := Id} = POI) ->
8683
[
8784
POI#{id => {Id, any_arity}, kind => application},
@@ -105,10 +102,8 @@ goto_definition(Uri, [#{id := FunId, kind := function} = POI | Rest]) ->
105102
%% cursor is not over a function - continue
106103
case els_code_navigation:goto_definition(Uri, POI) of
107104
{ok, Definitions} ->
108-
?LOG_INFO("found definitions: ~p", [Definitions]),
109105
goto_definitions_to_goto(Definitions);
110106
_ ->
111-
?LOG_INFO("try rest..."),
112107
goto_definition(Uri, Rest)
113108
end;
114109
Behaviours ->
@@ -124,14 +119,11 @@ goto_definition(Uri, [#{id := FunId, kind := function} = POI | Rest]) ->
124119
goto_definitions_to_goto(Definitions)
125120
end
126121
end;
127-
goto_definition(Uri, [#{id := Id} = POI | Rest]) ->
128-
?LOG_INFO("goto: ~p", [Id]),
122+
goto_definition(Uri, [POI | Rest]) ->
129123
case els_code_navigation:goto_definition(Uri, POI) of
130124
{ok, Definitions} ->
131-
?LOG_INFO("got definitions: ~p", [Definitions]),
132125
goto_definitions_to_goto(Definitions);
133126
_ ->
134-
?LOG_INFO("try rest... ~p", [Rest]),
135127
goto_definition(Uri, Rest)
136128
end.
137129

0 commit comments

Comments
 (0)