@@ -51,11 +51,27 @@ let findCallFromArgument text offset =
51
51
in
52
52
loop ~i: offset ~n Closed:0
53
53
54
- (* Figure out whether id should be autocompleted as component prop. *)
55
- (* Find JSX context ctx for component M to autocomplete id (already parsed) as a prop. *)
56
- (* ctx ::= <M args id *)
57
- (* arg ::= id | id = [?] val *)
58
- (* val ::= id | "abc" | 42 | {...} | (...) | [...] *)
54
+ (* skip A or #A if present *)
55
+ let skipOptVariant text i =
56
+ prerr_endline " skipOptIdent" ;
57
+ if i > 0 then
58
+ match text.[i] with
59
+ | 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' ->
60
+ let i = startOfLident text i - 1 in
61
+ let i =
62
+ if i > 0 then match text.[i] with '#' -> i - 1 | _ -> i else i
63
+ in
64
+ i
65
+ | _ -> i
66
+ else i
67
+
68
+ (* Figure out whether id should be autocompleted as component prop.
69
+ Find JSX context ctx for component M to autocomplete id (already parsed) as a prop.
70
+ ctx ::= <M args id
71
+ arg ::= id | id = [?] val
72
+ val ::= id | "abc" | 42 | {...} | optVariant (...) | [...]
73
+ optVariant ::= A | #a | _nothing_
74
+ *)
59
75
let findJsxContext text offset =
60
76
let rec loop identsSeen i =
61
77
let i = skipWhite text i in
@@ -66,7 +82,7 @@ let findJsxContext text offset =
66
82
if i1 > 0 then beforeValue identsSeen i1 else None
67
83
| ')' ->
68
84
let i1 = findBackSkippingCommentsAndStrings text '(' ')' (i - 1 ) 0 in
69
- if i1 > 0 then beforeValue identsSeen i1 else None
85
+ if i1 > 0 then beforeParen identsSeen i1 else None
70
86
| ']' ->
71
87
let i1 = findBackSkippingCommentsAndStrings text '[' ']' (i - 1 ) 0 in
72
88
if i1 > 0 then beforeValue identsSeen i1 else None
@@ -91,6 +107,9 @@ let findJsxContext text offset =
91
107
| '=' -> fromEquals identsSeen i
92
108
| _ -> loop identsSeen (i - 1 )
93
109
else None
110
+ and beforeParen identsSeen i =
111
+ let i = skipWhite text i in
112
+ beforeValue identsSeen (skipOptVariant text i)
94
113
and beforeValue identsSeen i =
95
114
let i = skipWhite text i in
96
115
if i > 0 then
0 commit comments