@@ -28,14 +28,69 @@ handle_request({definition, Params}) ->
28
28
IncompletePOIs = match_incomplete (Text , {Line , Character }),
29
29
case goto_definition (Uri , IncompletePOIs ) of
30
30
null ->
31
- els_references_provider :handle_request ({references , Params });
31
+ FuzzyPOIs = make_fuzzy (POIs ),
32
+ case goto_definition (Uri , FuzzyPOIs ) of
33
+ null ->
34
+ els_references_provider :handle_request ({references , Params });
35
+ GoTo ->
36
+ {response , GoTo }
37
+ end ;
32
38
GoTo ->
33
39
{response , GoTo }
34
40
end ;
35
41
GoTo ->
36
42
{response , GoTo }
37
43
end .
38
44
45
+ -spec make_fuzzy ([els_poi :poi ()]) -> [els_poi :poi ()].
46
+ make_fuzzy (POIs ) ->
47
+ lists :flatmap (
48
+ fun
49
+ (#{kind := application , id := {M , F , _A }} = POI ) ->
50
+ [
51
+ POI #{id => {M , F , any_arity }, kind => application },
52
+ POI #{id => {M , F , any_arity }, kind => type_application }
53
+ ];
54
+ (#{kind := type_application , id := {M , F , _A }} = POI ) ->
55
+ [
56
+ POI #{id => {M , F , any_arity }, kind => type_application },
57
+ POI #{id => {M , F , any_arity }, kind => application }
58
+ ];
59
+ (#{kind := application , id := {F , _A }} = POI ) ->
60
+ [
61
+ POI #{id => {F , any_arity }, kind => application },
62
+ POI #{id => {F , any_arity }, kind => type_application },
63
+ POI #{id => {F , any_arity }, kind => macro },
64
+ POI #{id => F , kind => macro }
65
+ ];
66
+ (#{kind := type_application , id := {F , _A }} = POI ) ->
67
+ [
68
+ POI #{id => {F , any_arity }, kind => type_application },
69
+ POI #{id => {F , any_arity }, kind => application },
70
+ POI #{id => {F , any_arity }, kind => macro },
71
+ POI #{id => F , kind => macro }
72
+ ];
73
+ (#{kind := macro , id := {M , _A }} = POI ) ->
74
+ [
75
+ POI #{id => M },
76
+ POI #{id => {M , any_arity }}
77
+ ];
78
+ (#{kind := macro , id := M } = POI ) ->
79
+ [
80
+ POI #{id => {M , any_arity }}
81
+ ];
82
+ (#{kind := atom , id := Id } = POI ) ->
83
+ [
84
+ POI #{id => {Id , any_arity }, kind => application },
85
+ POI #{id => {Id , any_arity }, kind => type_application },
86
+ POI #{id => Id , kind => macro }
87
+ ];
88
+ (_POI ) ->
89
+ []
90
+ end ,
91
+ POIs
92
+ ).
93
+
39
94
- spec goto_definition (uri (), [els_poi :poi ()]) -> [map ()] | null .
40
95
goto_definition (_Uri , []) ->
41
96
null ;
0 commit comments