Skip to content

Commit 5c7be4c

Browse files
committed
Add test for function call, and support for list{...}.
1 parent 700debd commit 5c7be4c

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## master
2-
- ppx autocomplete: handle variant and polymorphic variant without braces.
2+
- ppx autocomplete: handle values to the rhs of `=` without braces (variant, polymorphic variant, function call, list literal).
33

44
## 1.1.1
55

analysis/src/PartialParser.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ let skipOptVariant text i =
6969
Find JSX context ctx for component M to autocomplete id (already parsed) as a prop.
7070
ctx ::= <M args id
7171
arg ::= id | id = [?] val
72-
val ::= id | "abc" | 42 | {...} | optVariant (...) | [...]
73-
optVariant ::= A | #a | _nothing_
72+
val ::= id | "abc" | 42 | optVariant {...} | optVariant (...) | [...]
73+
optVariant ::= a | A | #a | #A | _nothing_
7474
*)
7575
let findJsxContext text offset =
7676
let rec loop identsSeen i =
@@ -79,7 +79,7 @@ let findJsxContext text offset =
7979
match text.[i] with
8080
| '}' ->
8181
let i1 = findBackSkippingCommentsAndStrings text '{' '}' (i - 1) 0 in
82-
if i1 > 0 then beforeValue identsSeen i1 else None
82+
if i1 > 0 then beforeParen identsSeen i1 else None
8383
| ')' ->
8484
let i1 = findBackSkippingCommentsAndStrings text '(' ')' (i - 1) 0 in
8585
if i1 > 0 then beforeParen identsSeen i1 else None

analysis/tests/src/Jsx.res

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ let y = 44
2121

2222
//^com <M prop=A(3) k
2323

24+
//^com <M prop=foo(1+2) k
25+
26+
//^com <M prop=list{1,2,3} k
2427

25-
//^com <M prop = #A (3) k

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Complete tests/src/Jsx.res 11:2
7171
}]
7272

7373
Complete tests/src/Jsx.res 18:2
74+
skipOptIdent
7475
[{
7576
"label": "key",
7677
"kind": 4,
@@ -89,7 +90,17 @@ skipOptIdent
8990
"documentation": null
9091
}]
9192

92-
Complete tests/src/Jsx.res 23:2
93+
Complete tests/src/Jsx.res 22:2
94+
skipOptIdent
95+
[{
96+
"label": "key",
97+
"kind": 4,
98+
"tags": [],
99+
"detail": "string",
100+
"documentation": null
101+
}]
102+
103+
Complete tests/src/Jsx.res 24:2
93104
skipOptIdent
94105
[{
95106
"label": "key",

0 commit comments

Comments
 (0)