@@ -27,11 +27,16 @@ let getLocItem ~full ~pos ~debug =
27
27
print_endline
28
28
(" locItems:\n "
29
29
^ (locItems |> List. map locItemToString |> String. concat " \n " ));
30
+ let nameOf li =
31
+ match li.locType with Typed (n , _ , _ ) -> n | _ -> " NotFound"
32
+ in
30
33
match locItems with
31
- | _ :: _ :: _ :: ({locType = Typed (" makeProps" , _, _)} as li ) :: _
34
+ | li1 :: li2 :: li3 :: ({locType = Typed (" makeProps" , _, _)} as li4 ) :: _
32
35
when full.file.uri |> Uri2. isInterface ->
33
36
log 1 " heuristic for makeProps in interface files" ;
34
- Some li
37
+ if debug then
38
+ Printf. printf " n1:%s n2:%s n3:%s\n " (nameOf li1) (nameOf li2) (nameOf li3);
39
+ Some li4
35
40
| [
36
41
{locType = Typed (" fragment" , _, _)};
37
42
{locType = Typed (" createElement" , _, _)};
@@ -51,13 +56,17 @@ let getLocItem ~full ~pos ~debug =
51
56
work\n \
52
57
the type is not great but jump to definition works" ;
53
58
Some li2
54
- | [({locType = Typed (_, _, LocalReference _)} as li1); li3]
55
- when li1.loc = li3.loc ->
59
+ | [
60
+ ({locType = Typed (_, _, LocalReference _)} as li1);
61
+ ({locType = Typed (_, _, _)} as li2);
62
+ ]
63
+ when li1.loc = li2.loc ->
56
64
log 5
57
65
" heuristic for JSX and compiler combined:\n \
58
66
~x becomes Props#x\n \
59
67
heuristic for: [Props, x], give loc of `x`" ;
60
- Some li3
68
+ if debug then Printf. printf " n1:%s n2:%s\n " (nameOf li1) (nameOf li2);
69
+ Some li2
61
70
| [
62
71
({locType = Typed (_, _, LocalReference _)} as li1);
63
72
({locType = Typed (_, _, GlobalReference (" Js_OO" , [" unsafe_downgrade" ], _))}
@@ -73,7 +82,7 @@ let getLocItem ~full ~pos ~debug =
73
82
heuristic for: [Props, unsafe_downgrade, x], give loc of `x`" ;
74
83
Some li3
75
84
| [
76
- {locType = Typed (_, _, LocalReference (_, Value ))};
85
+ ( {locType = Typed (_, _, LocalReference (_, Value ))} as li1) ;
77
86
({locType = Typed (_, _, Definition (_, Value ))} as li2);
78
87
] ->
79
88
log 7
@@ -82,6 +91,7 @@ let getLocItem ~full ~pos ~debug =
82
91
Props has the location range of arg:t\n \
83
92
arg has the location range of arg\n \
84
93
heuristic for: [Props, arg], give loc of `arg`" ;
94
+ if debug then Printf. printf " n1:%s n2:%s\n " (nameOf li1) (nameOf li2);
85
95
Some li2
86
96
| [li1; li2; li3] when li1.loc = li2.loc && li2.loc = li3.loc ->
87
97
(* Not currently testable on 9.1.4 *)
@@ -93,8 +103,11 @@ let getLocItem ~full ~pos ~debug =
93
103
when li1.loc = li2.loc && li2.loc = li3.loc && li3.loc = li4.loc ->
94
104
log 9
95
105
" heuristic for JSX variadic, e.g. <C> {x} {y} </C>\n \
96
- heuristic for: [makeProps , React.null, make, createElementVariadic], \
106
+ heuristic for: [React.null, makeProps , make, createElementVariadic], \
97
107
give the loc of `make`" ;
108
+ if debug then
109
+ Printf. printf " n1:%s n2:%s n3:%s n4:%s\n " (nameOf li1) (nameOf li2)
110
+ (nameOf li3) (nameOf li4);
98
111
Some li3
99
112
| {locType = Typed (_, {desc = Tconstr (path, _, _)}, _)} :: li :: _
100
113
when Utils. isUncurriedInternal path ->
0 commit comments