@@ -109,7 +109,7 @@ let skipOptVariantExtension text i =
109
109
arg ::= id | id = [?] atomicExpr
110
110
atomicExpr ::= id | "abc" | 'a' | 42 | `...` | optVariant {...} | optVariant (...) | <...> | [...]
111
111
optVariant ::= a | A | #a | #A | _nothing_
112
- *)
112
+ *)
113
113
let findJsxContext text offset =
114
114
let rec loop identsSeen i =
115
115
let i = skipWhite text i in
@@ -187,6 +187,7 @@ type completable =
187
187
| Cpath of string list (* * e.g. ["M", "foo"] for M.foo *)
188
188
| Cjsx of string list * string * string list
189
189
(* * E.g. (["M", "Comp"], "id", ["id1", "id2"]) for <M.Comp id1=... id2=... ... id *)
190
+ | Cobj of string * string (* * e.g. ("foo", "bar") for foo['bar *)
190
191
| Cpipe of pipe * string (* * E.g. ("x", "foo") for "x->foo" *)
191
192
192
193
let isLowercaseIdent id =
@@ -228,6 +229,19 @@ let findCompletable text offset =
228
229
| None -> None
229
230
| Some lhs -> Some (Cpipe (lhs, partialName))
230
231
in
232
+ let mkObj ~off ~partialName =
233
+ let off = skipWhite text off in
234
+ let rec loop i =
235
+ if i < 0 then Some (String. sub text 0 (i - 1 ))
236
+ else
237
+ match text.[i] with
238
+ | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> loop (i - 1 )
239
+ | _ -> Some (String. sub text (i + 1 ) (off - i))
240
+ in
241
+ match loop off with
242
+ | None -> None
243
+ | Some lhs -> Some (Cobj (lhs, partialName))
244
+ in
231
245
232
246
let suffix i = String. sub text (i + 1 ) (offset - (i + 1 )) in
233
247
let rec loop i =
@@ -243,6 +257,9 @@ let findCompletable text offset =
243
257
let funPath, identsSeen = findCallFromArgument text (i - 1 ) in
244
258
Some (Clabel (funPath, labelPrefix, identsSeen))
245
259
| '@' -> Some (Cdecorator (suffix i))
260
+ | '"' when i > 0 && text.[i - 1 ] = '[' ->
261
+ let partialName = suffix i in
262
+ mkObj ~off: (i - 2 ) ~partial Name
246
263
| 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '.' | '_' -> loop (i - 1 )
247
264
| ' ' when i = offset - 1 -> (
248
265
(* autocomplete with no id: check if inside JSX *)
0 commit comments