Skip to content

Commit 3f66037

Browse files
committed
Add heuristic for lowercase jsx.
Show the type of, and jump to, `createDOMElementVariadic`.
1 parent c832a65 commit 3f66037

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Autocomplete for function calls: only suggest labeled args that were not yet assigned.
44
- Add support for recursive modules.
55
- Add support for transitive module references.
6+
- Add heuristic for lowercase jsx.
67

78
## 1.1.1
89

analysis/src/References.ml

+8-5
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,29 @@ let locItemsForPos ~extra pos =
1919

2020
let locItemForPos ~full pos =
2121
let locItems = locItemsForPos ~extra:full.extra pos in
22-
if !Log.spamError then
22+
if !Log.spamError then
2323
print_endline
2424
("locItems:\n"
2525
^ (locItems |> List.map locItemToString |> String.concat "\n"));
2626
match locItems with
27-
| _ :: _ :: _ :: ({locType = Typed ("makeProps", _, _)} as l) :: _
27+
| _ :: _ :: _ :: ({locType = Typed ("makeProps", _, _)} as li) :: _
2828
when full.file.uri |> Uri2.isInterface ->
2929
(* heuristic for makeProps in interface files *)
30-
Some l
30+
Some li
3131
| [
3232
{locType = Typed ("fragment", _, _)};
3333
{locType = Typed ("createElement", _, _)};
3434
] ->
3535
(* heuristic for </Comp> within a fragment *)
3636
None
37+
| [{locType = Constant _}; ({locType = Typed ("createDOMElementVariadic", _, _)} as li2)] ->
38+
(* heuristic for <div> *)
39+
Some li2
3740
| {locType = Typed ("makeProps", _, _)}
38-
:: ({locType = Typed ("make", _, _)} as l2) :: _ ->
41+
:: ({locType = Typed ("make", _, _)} as li2) :: _ ->
3942
(* heuristic for </Comp> within fragments: take make as makeProps does not work
4043
the type is not greatl but jump to definition works *)
41-
Some l2
44+
Some li2
4245
| [({locType = Typed (_, _, LocalReference _)} as li1); li3]
4346
when li1.loc = li3.loc ->
4447
(* JSX and compiler combined:

analysis/tests/src/Div.res

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
let q = <div> </div>
3+
// ^hov
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Hover tests/src/Div.res 1:10
2+
{"contents": "```rescript\n(\n string,\n ~?props: ReactDOMRe.domProps,\n array<React.element>,\n) => React.element\n```"}
3+

0 commit comments

Comments
 (0)