Skip to content

Commit 5207f77

Browse files
committed
More cases of atomic expressions to assigned to props.
1 parent 12b8728 commit 5207f77

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

analysis/src/PartialParser.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ let skipOptVariant text i =
6868
(* Figure out whether id should be autocompleted as component prop.
6969
Find JSX context ctx for component M to autocomplete id (already parsed) as a prop.
7070
ctx ::= <M args id
71-
arg ::= id | id = [?] val
72-
val ::= id | "abc" | 42 | optVariant {...} | optVariant (...) | <...> | [...]
71+
arg ::= id | id = [?] atomicExpr
72+
atomicExpr ::= id | "abc" | 'a' | 42 | `...` | optVariant {...} | optVariant (...) | <...> | [...]
7373
optVariant ::= a | A | #a | #A | _nothing_
7474
*)
7575
let findJsxContext text offset =
@@ -92,6 +92,12 @@ let findJsxContext text offset =
9292
| '"' ->
9393
let i1 = findBack text '"' (i - 1) in
9494
if i1 > 0 then beforeValue identsSeen i1 else None
95+
| '\'' ->
96+
let i1 = findBack text '\'' (i - 1) in
97+
if i1 > 0 then beforeValue identsSeen i1 else None
98+
| '`' ->
99+
let i1 = findBack text '`' (i - 1) in
100+
if i1 > 0 then beforeValue identsSeen i1 else None
95101
| _ ->
96102
let i1 = startOfLident text i in
97103
let ident = String.sub text i1 (i - i1 + 1) in

analysis/tests/src/Jsx.res

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ let y = 44
2626
//^com <M prop=list{1,2,3} k
2727

2828
//^com <M prop=<N /> k
29+
30+
//^com <M prop=1.5 k
31+
32+
//^com <M prop=0X33 k
33+
34+
//^com <M prop=12e+3 k
35+
36+
//^com <M prop='z' k
37+
38+
//^com <M prop=`before${foo}` k
39+
40+
//<M prop=module(@foo Three: X_int) k
41+
42+
//<M prop=%bs.raw("1") k

analysis/tests/src/expected/Jsx.res.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,48 @@ Complete tests/src/Jsx.res 26:2
119119
"documentation": null
120120
}]
121121

122+
Complete tests/src/Jsx.res 28:2
123+
[{
124+
"label": "key",
125+
"kind": 4,
126+
"tags": [],
127+
"detail": "string",
128+
"documentation": null
129+
}]
130+
131+
Complete tests/src/Jsx.res 30:2
132+
[{
133+
"label": "key",
134+
"kind": 4,
135+
"tags": [],
136+
"detail": "string",
137+
"documentation": null
138+
}]
139+
140+
Complete tests/src/Jsx.res 32:2
141+
[{
142+
"label": "key",
143+
"kind": 4,
144+
"tags": [],
145+
"detail": "string",
146+
"documentation": null
147+
}]
148+
149+
Complete tests/src/Jsx.res 34:2
150+
[{
151+
"label": "key",
152+
"kind": 4,
153+
"tags": [],
154+
"detail": "string",
155+
"documentation": null
156+
}]
157+
158+
Complete tests/src/Jsx.res 36:2
159+
[{
160+
"label": "key",
161+
"kind": 4,
162+
"tags": [],
163+
"detail": "string",
164+
"documentation": null
165+
}]
166+

0 commit comments

Comments
 (0)